Added const qualifiers

String literals in C++ are implicitly typed as 'const char *', and with
this change, their const-ness is maintained when assigning them to
variables or passing them as arguments. This significantly cuts down the
number of warnings generated by the compiler.
pull/3/head
Daniel Richard G 2013-08-26 14:58:35 -04:00
parent affbeafc6c
commit 02776ea535
25 changed files with 121 additions and 121 deletions

View File

@ -9,7 +9,7 @@
char *Constraint::DescriptionString(void) {
static char ret[1024];
char *s;
const char *s;
switch(type) {
case POINTS_COINCIDENT: s = "pts-coincident"; break;
case PT_PT_DISTANCE: s = "pt-pt-distance"; break;

View File

@ -980,9 +980,9 @@ s:
if(type == AT_MIDPOINT) offset = offset.ScaledBy(-1);
if(dogd.drawing) {
char *s = (type == HORIZONTAL) ? "H" : (
(type == VERTICAL) ? "V" : (
(type == AT_MIDPOINT) ? "M" : NULL));
const char *s = (type == HORIZONTAL) ? "H" : (
(type == VERTICAL) ? "V" : (
(type == AT_MIDPOINT) ? "M" : NULL));
glxWriteTextRefCenter(s, DEFAULT_TEXT_HEIGHT,
m.Plus(offset), r, u, LineCallback, this);

2
dsc.h
View File

@ -373,7 +373,7 @@ class NameStr {
public:
char str[64];
inline void strcpy(char *in) {
inline void strcpy(const char *in) {
memcpy(str, in, min(strlen(in)+1, sizeof(str)));
str[sizeof(str)-1] = '\0';
}

View File

@ -519,12 +519,12 @@ hParam Expr::ReferencedParams(ParamList *pl) {
//-----------------------------------------------------------------------------
static char StringBuffer[4096];
void Expr::App(char *s, ...) {
void Expr::App(const char *s, ...) {
va_list f;
va_start(f, s);
vsprintf(StringBuffer+strlen(StringBuffer), s, f);
}
char *Expr::Print(void) {
const char *Expr::Print(void) {
if(!this) return "0";
StringBuffer[0] = '\0';

4
expr.h
View File

@ -94,8 +94,8 @@ public:
void ParamsToPointers(void);
void App(char *str, ...);
char *Print(void);
void App(const char *str, ...);
const char *Print(void);
void PrintW(void); // worker
// number of child nodes: 0 (e.g. constant), 1 (sqrt), or 2 (+)

View File

@ -7,7 +7,7 @@
#define VERSION_STRING "±²³SolveSpaceREVa"
static int StrStartsWith(char *str, char *start) {
static int StrStartsWith(const char *str, const char *start) {
return memcmp(str, start, strlen(start)) == 0;
}

View File

@ -15,7 +15,7 @@ static bool ColorLocked;
static bool DepthOffsetLocked;
#define FONT_SCALE(h) ((h)/22.0)
double glxStrWidth(char *str, double h)
double glxStrWidth(const char *str, double h)
{
int w = 0;
for(; *str; str++) {
@ -32,8 +32,8 @@ double glxStrHeight(double h)
// The characters have height ~22, as they appear in the table.
return 22.0*FONT_SCALE(h)/SS.GW.scale;
}
void glxWriteTextRefCenter(char *str, double h, Vector t, Vector u, Vector v,
glxLineFn *fn, void *fndata)
void glxWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector v,
glxLineFn *fn, void *fndata)
{
u = u.WithMagnitude(1);
v = v.WithMagnitude(1);
@ -61,8 +61,8 @@ static void LineDrawCallback(void *fndata, Vector a, Vector b)
glEnd();
}
void glxWriteText(char *str, double h, Vector t, Vector u, Vector v,
glxLineFn *fn, void *fndata)
void glxWriteText(const char *str, double h, Vector t, Vector u, Vector v,
glxLineFn *fn, void *fndata)
{
if(!fn) fn = LineDrawCallback;
u = u.WithMagnitude(1);
@ -549,7 +549,7 @@ void glxBitmapCharQuad(char c, double x, double y)
}
}
void glxBitmapText(char *str, Vector p)
void glxBitmapText(const char *str, Vector p)
{
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);

View File

@ -816,7 +816,7 @@ void GraphicsWindow::MenuEdit(int id) {
}
void GraphicsWindow::MenuRequest(int id) {
char *s;
const char *s;
switch(id) {
case MNU_SEL_WORKPLANE: {
SS.GW.GroupSelection();

View File

@ -509,7 +509,7 @@ void Group::Draw(void) {
if(type == DRAWING_WORKPLANE) {
glDisable(GL_DEPTH_TEST);
glxColorRGB(Style::Color(Style::DRAW_ERROR));
char *msg;
const char *msg;
if(polyError.how == POLY_NOT_COPLANAR) {
msg = "points not all coplanar!";
} else if(polyError.how == POLY_SELF_INTERSECTING) {

View File

@ -25,7 +25,7 @@ const EntReqTable::TableEntry EntReqTable::Table[] = {
{ 0 },
};
char *EntReqTable::DescriptionForRequest(int req) {
const char *EntReqTable::DescriptionForRequest(int req) {
for(int i = 0; Table[i].reqType; i++) {
if(req == Table[i].reqType) {
return Table[i].description;
@ -174,7 +174,7 @@ void Request::Generate(IdList<Entity,hEntity> *entity,
}
char *Request::DescriptionString(void) {
char *s;
const char *s;
if(h.v == Request::HREQUEST_REFERENCE_XY.v) {
s = "#XY";
} else if(h.v == Request::HREQUEST_REFERENCE_YZ.v) {

View File

@ -466,18 +466,18 @@ public:
class EntReqTable {
public:
typedef struct {
int reqType;
int entType;
int points;
bool useExtraPoints;
bool hasNormal;
bool hasDistance;
char *description;
int reqType;
int entType;
int points;
bool useExtraPoints;
bool hasNormal;
bool hasDistance;
const char *description;
} TableEntry;
static const TableEntry Table[];
static char *DescriptionForRequest(int req);
static const char *DescriptionForRequest(int req);
static void CopyEntityInfo(const TableEntry *te, int extraPoints,
int *ent, int *req, int *pts, bool *hasNormal, bool *hasDistance);
static bool GetRequestInfo(int req, int extraPoints,
@ -704,16 +704,16 @@ public:
// The default styles, for entities that don't have a style assigned yet,
// and for datums and such.
typedef struct {
hStyle h;
char *cnfPrefix;
DWORD color;
double width;
hStyle h;
const char *cnfPrefix;
DWORD color;
double width;
} Default;
static const Default Defaults[];
static char *CnfColor(char *prefix);
static char *CnfWidth(char *prefix);
static char *CnfPrefixToName(char *prefix);
static char *CnfColor(const char *prefix);
static char *CnfWidth(const char *prefix);
static char *CnfPrefixToName(const char *prefix);
static void CreateAllDefaultStyles(void);
static void CreateDefaultStyle(hStyle h);

View File

@ -200,7 +200,7 @@ double SolveSpace::MmPerUnit(void) {
return 1.0;
}
}
char *SolveSpace::UnitName(void) {
const char *SolveSpace::UnitName(void) {
if(viewUnits == UNIT_INCHES) {
return "inch";
} else {
@ -228,7 +228,7 @@ char *SolveSpace::MmToString(double v) {
double SolveSpace::ExprToMm(Expr *e) {
return (e->Eval()) * MmPerUnit();
}
double SolveSpace::StringToMm(char *str) {
double SolveSpace::StringToMm(const char *str) {
return atof(str) * MmPerUnit();
}
double SolveSpace::ChordTolMm(void) {
@ -530,10 +530,10 @@ void SolveSpace::MenuAnalyze(int id) {
InvalidateGraphics();
char *intersMsg = inters ?
const char *intersMsg = inters ?
"The mesh is self-intersecting (NOT okay, invalid)." :
"The mesh is not self-intersecting (okay, valid).";
char *leaksMsg = leaks ?
const char *leaksMsg = leaks ?
"The mesh has naked edges (NOT okay, invalid)." :
"The mesh is watertight (okay, valid).";

View File

@ -116,12 +116,12 @@ int SaveFileYesNoCancel(void);
// Comma-separated value, like a spreadsheet would use
#define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0"
#define CSV_EXT "csv"
BOOL GetSaveFile(char *file, char *defExtension, char *selPattern);
BOOL GetOpenFile(char *file, char *defExtension, char *selPattern);
BOOL GetSaveFile(char *file, const char *defExtension, const char *selPattern);
BOOL GetOpenFile(char *file, const char *defExtension, const char *selPattern);
void GetAbsoluteFilename(char *file);
void LoadAllFontFiles(void);
void OpenWebsite(char *url);
void OpenWebsite(const char *url);
void CheckMenuById(int id, BOOL checked);
void EnableMenuById(int id, BOOL checked);
@ -136,7 +136,7 @@ void MoveTextScrollbarTo(int pos, int maxPos, int page);
#define CONTEXT_SUBMENU (-1)
#define CONTEXT_SEPARATOR (-2)
void AddContextMenuItem(char *legend, int id);
void AddContextMenuItem(const char *legend, int id);
void CreateContextSubmenu(void);
int ShowContextMenu(void);
@ -149,23 +149,23 @@ void GetTextWindowSize(int *w, int *h);
SDWORD GetMilliseconds(void);
SQWORD GetUnixTime(void);
void dbp(char *str, ...);
void dbp(const char *str, ...);
#define DBPTRI(tri) \
dbp("tri: (%.3f %.3f %.3f) (%.3f %.3f %.3f) (%.3f %.3f %.3f)", \
CO((tri).a), CO((tri).b), CO((tri).c))
void SetWindowTitle(char *str);
void SetWindowTitle(const char *str);
void SetMousePointerToHand(bool yes);
void DoMessageBox(char *str, int rows, int cols, BOOL error);
void DoMessageBox(const char *str, int rows, int cols, BOOL error);
void SetTimerFor(int milliseconds);
void ExitNow(void);
void CnfFreezeString(char *str, char *name);
void CnfFreezeDWORD(DWORD v, char *name);
void CnfFreezeFloat(float v, char *name);
void CnfThawString(char *str, int maxLen, char *name);
DWORD CnfThawDWORD(DWORD v, char *name);
float CnfThawFloat(float v, char *name);
void CnfFreezeString(const char *str, const char *name);
void CnfFreezeDWORD(DWORD v, const char *name);
void CnfFreezeFloat(float v, const char *name);
void CnfThawString(char *str, int maxLen, const char *name);
DWORD CnfThawDWORD(DWORD v, const char *name);
float CnfThawFloat(float v, const char *name);
void *AllocTemporary(int n);
void FreeTemporary(void *p);
@ -212,11 +212,11 @@ void glxDrawEdges(SEdgeList *l, bool endpointsToo);
void glxDebugMesh(SMesh *m);
void glxMarkPolygonNormal(SPolygon *p);
typedef void glxLineFn(void *data, Vector a, Vector b);
void glxWriteText(char *str, double h, Vector t, Vector u, Vector v,
void glxWriteText(const char *str, double h, Vector t, Vector u, Vector v,
glxLineFn *fn, void *fndata);
void glxWriteTextRefCenter(char *str, double h, Vector t, Vector u, Vector v,
void glxWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector v,
glxLineFn *fn, void *fndata);
double glxStrWidth(char *str, double h);
double glxStrWidth(const char *str, double h);
double glxStrHeight(double h);
void glxLockColorTo(DWORD rgb);
void glxFatLine(Vector a, Vector b, double width);
@ -227,7 +227,7 @@ void glxDepthRangeOffset(int units);
void glxDepthRangeLockToFront(bool yes);
void glxDrawPixelsWithTexture(BYTE *data, int w, int h);
void glxCreateBitmapFont(void);
void glxBitmapText(char *str, Vector p);
void glxBitmapText(const char *str, Vector p);
void glxBitmapCharQuad(char c, double x, double y);
#define TEXTURE_BACKGROUND_IMG 10
#define TEXTURE_BITMAP_FONT 20
@ -242,12 +242,12 @@ void MakeMatrix(double *mat, double a11, double a12, double a13, double a14,
double a21, double a22, double a23, double a24,
double a31, double a32, double a33, double a34,
double a41, double a42, double a43, double a44);
void MakePathRelative(char *base, char *path);
void MakePathAbsolute(char *base, char *path);
bool StringAllPrintable(char *str);
bool StringEndsIn(char *str, char *ending);
void Message(char *str, ...);
void Error(char *str, ...);
void MakePathRelative(const char *base, char *path);
void MakePathAbsolute(const char *base, char *path);
bool StringAllPrintable(const char *str);
bool StringEndsIn(const char *str, const char *ending);
void Message(const char *str, ...);
void Error(const char *str, ...);
class System {
public:
@ -379,7 +379,7 @@ public:
void LoadGlyph(int index);
bool LoadFontFromFile(bool nameOnly);
char *FontFileBaseName(void);
const char *FontFileBaseName(void);
void Flush(void);
void Handle(int *dx, int x, int y, bool onCurve);
@ -651,8 +651,8 @@ public:
char *MmToString(double v);
double ExprToMm(Expr *e);
double StringToMm(char *s);
char *UnitName(void);
double StringToMm(const char *s);
const char *UnitName(void);
double MmPerUnit(void);
int UnitDigitsAfterDecimal(void);
void SetUnitDigitsAfterDecimal(int v);
@ -680,10 +680,10 @@ public:
bool fileLoadError;
bool unsaved;
typedef struct {
char type;
char *desc;
char fmt;
void *ptr;
char type;
const char *desc;
char fmt;
void *ptr;
} SaveTable;
static const SaveTable SAVED[];
void SaveUsingTable(int type);

View File

@ -291,7 +291,7 @@ void DEBUGEDGELIST(SEdgeList *sel, SSurface *surf) {
}
}
static char *REGION(int d) {
static const char *REGION(int d) {
switch(d) {
case SShell::INSIDE: return "inside";
case SShell::OUTSIDE: return "outside";

View File

@ -25,18 +25,18 @@ const Style::Default Style::Defaults[] = {
{ 0, NULL, 0, 0.0, },
};
char *Style::CnfColor(char *prefix) {
char *Style::CnfColor(const char *prefix) {
static char name[100];
sprintf(name, "Style_%s_Color", prefix);
return name;
}
char *Style::CnfWidth(char *prefix) {
char *Style::CnfWidth(const char *prefix) {
static char name[100];
sprintf(name, "Style_%s_Width", prefix);
return name;
}
char *Style::CnfPrefixToName(char *prefix) {
char *Style::CnfPrefixToName(const char *prefix) {
static char name[100];
int i = 0, j;
strcpy(name, "#def-");
@ -789,7 +789,7 @@ void TextWindow::ShowStyleInfo(void) {
Printf(false, "");
Printf(false, "%Ft text comment style%E");
char *chng = (s->h.v < Style::FIRST_CUSTOM) ? "" : "[change]";
const char *chng = (s->h.v < Style::FIRST_CUSTOM) ? "" : "[change]";
if(s->textHeightAs == Style::UNITS_AS_PIXELS) {
Printf(false, "%Ba %Ftheight %E%@ %D%f%Lt%Fl%s%E",
s->textHeight,

View File

@ -269,7 +269,7 @@ void TextWindow::ScreenDeleteGroup(int link, DWORD v) {
}
void TextWindow::ShowGroupInfo(void) {
Group *g = SK.group.FindById(shown.group);
char *s = "???";
const char *s = "???";
if(shown.group.v == Group::HGROUP_REFERENCES.v) {
Printf(true, "%FtGROUP %E%s", g->DescriptionString());

View File

@ -115,7 +115,7 @@ void TextWindow::ClearScreen(void) {
rows = 0;
}
void TextWindow::Printf(bool halfLine, char *fmt, ...) {
void TextWindow::Printf(bool halfLine, const char *fmt, ...) {
va_list vl;
va_start(vl, fmt);

View File

@ -12,7 +12,7 @@ BYTE SPACER[1];
static const struct {
BYTE *image;
int menu;
char *tip;
const char *tip;
} Toolbar[] = {
{ Icon_line, GraphicsWindow::MNU_LINE_SEGMENT, "Sketch line segment" },
{ Icon_rectangle, GraphicsWindow::MNU_RECTANGLE, "Sketch rectangle" },
@ -136,7 +136,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
struct {
bool show;
char *str;
const char *str;
} toolTip = { false, NULL };
bool leftpos = true;

View File

@ -223,7 +223,7 @@ void TtfFont::LoadGlyph(int index) {
// Return the basename of our font filename; that's how the requests and
// entities that reference us will store it.
//-----------------------------------------------------------------------------
char *TtfFont::FontFileBaseName(void) {
const char *TtfFont::FontFileBaseName(void) {
char *sb = strrchr(fontFile, '\\');
char *sf = strrchr(fontFile, '/');
char *s = sf ? sf : sb;

12
ui.h
View File

@ -66,9 +66,9 @@ public:
// The row of icons at the top of the text window, to hide/show things
typedef struct {
bool *var;
BYTE *icon;
char *tip;
bool *var;
BYTE *icon;
const char *tip;
} HideShowIcon;
static HideShowIcon hideShowIcons[];
static bool SPACER;
@ -96,7 +96,7 @@ public:
void Init(void);
void MakeColorTable(const Color *in, float *out);
void Printf(bool half, char *fmt, ...);
void Printf(bool half, const char *fmt, ...);
void ClearScreen(void);
void Show(void);
@ -417,7 +417,7 @@ public:
typedef void MenuHandler(int id);
typedef struct {
int level; // 0 == on menu bar, 1 == one level down
char *label; // or NULL for a separator
const char *label; // or NULL for a separator
int id; // unique ID
int accel; // keyboard accelerator
MenuHandler *fn;
@ -507,7 +507,7 @@ public:
hEntity normal;
hConstraint constraint;
char *description;
const char *description;
} pending;
void ClearPending(void);
// The constraint that is being edited with the on-screen textbox.

View File

@ -6,10 +6,10 @@
//-----------------------------------------------------------------------------
#include "solvespace.h"
void MakePathRelative(char *basep, char *pathp)
void MakePathRelative(const char *basep, char *pathp)
{
int i;
char *p;
const char *p;
char base[MAX_PATH], path[MAX_PATH], out[MAX_PATH];
// Convert everything to lowercase
@ -65,7 +65,7 @@ void MakePathRelative(char *basep, char *pathp)
strcpy(pathp, out);
}
void MakePathAbsolute(char *basep, char *pathp) {
void MakePathAbsolute(const char *basep, char *pathp) {
char out[MAX_PATH];
strcpy(out, basep);
@ -83,9 +83,9 @@ void MakePathAbsolute(char *basep, char *pathp) {
strcpy(pathp, out);
}
bool StringAllPrintable(char *str)
bool StringAllPrintable(const char *str)
{
char *t;
const char *t;
for(t = str; *t; t++) {
if(!(isalnum(*t) || *t == '-' || *t == '_')) {
return false;
@ -94,7 +94,7 @@ bool StringAllPrintable(char *str)
return true;
}
bool StringEndsIn(char *str, char *ending)
bool StringEndsIn(const char *str, const char *ending)
{
int i, ls = strlen(str), le = strlen(ending);
@ -135,7 +135,7 @@ void MakeMatrix(double *mat, double a11, double a12, double a13, double a14,
// Word-wrap the string for our message box appropriately, and then display
// that string.
//-----------------------------------------------------------------------------
static void DoStringForMessageBox(char *str, va_list f, bool error)
static void DoStringForMessageBox(const char *str, va_list f, bool error)
{
char inBuf[1024*50];
vsprintf(inBuf, str, f);
@ -190,14 +190,14 @@ static void DoStringForMessageBox(char *str, va_list f, bool error)
// And then display the text with our actual longest line length.
DoMessageBox(outBuf, rows, cols, error);
}
void Error(char *str, ...)
void Error(const char *str, ...)
{
va_list f;
va_start(f, str);
DoStringForMessageBox(str, f, true);
va_end(f);
}
void Message(char *str, ...)
void Message(const char *str, ...)
{
va_list f;
va_start(f, str);

View File

@ -10,7 +10,7 @@
/*
* store a window's position in the registry, or fail silently if the registry calls don't work
*/
void FreezeWindowPosF(HWND hwnd, char *subKey, char *name)
void FreezeWindowPosF(HWND hwnd, const char *subKey, const char *name)
{
RECT r;
GetWindowRect(hwnd, &r);
@ -60,7 +60,7 @@ static void Clamp(LONG *v, LONG min, LONG max)
/*
* retrieve a window's position from the registry, or do nothing if there is no info saved
*/
void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
void ThawWindowPosF(HWND hwnd, const char *subKey, const char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
@ -132,7 +132,7 @@ void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
/*
* store a DWORD setting in the registry
*/
void FreezeDWORDF(DWORD val, char *subKey, char *name)
void FreezeDWORDF(DWORD val, const char *subKey, const char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
@ -149,7 +149,7 @@ void FreezeDWORDF(DWORD val, char *subKey, char *name)
/*
* retrieve a DWORD setting, or return the default if that setting is unavailable
*/
DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
DWORD ThawDWORDF(DWORD val, const char *subKey, const char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
@ -170,7 +170,7 @@ DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
/*
* store a string setting in the registry
*/
void FreezeStringF(char *val, char *subKey, char *name)
void FreezeStringF(const char *val, const char *subKey, const char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
@ -180,14 +180,14 @@ void FreezeStringF(char *val, char *subKey, char *name)
if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
return;
if(RegSetValueEx(sub, name, 0, REG_SZ, (BYTE *)val, strlen(val)+1) != ERROR_SUCCESS)
if(RegSetValueEx(sub, name, 0, REG_SZ, (const BYTE *)val, strlen(val)+1) != ERROR_SUCCESS)
return;
}
/*
* retrieve a string setting, or return the default if that setting is unavailable
*/
void ThawStringF(char *val, int max, char *subKey, char *name)
void ThawStringF(char *val, int max, const char *subKey, const char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)

View File

@ -12,22 +12,22 @@
#endif
#define FreezeWindowPos(hwnd) FreezeWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
void FreezeWindowPosF(HWND hWnd, char *subKey, char *name);
void FreezeWindowPosF(HWND hWnd, const char *subKey, const char *name);
#define ThawWindowPos(hwnd) ThawWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
void ThawWindowPosF(HWND hWnd, char *subKey, char *name);
void ThawWindowPosF(HWND hWnd, const char *subKey, const char *name);
#define FreezeDWORD(val) FreezeDWORDF(val, FREEZE_SUBKEY, #val)
void FreezeDWORDF(DWORD val, char *subKey, char *name);
void FreezeDWORDF(DWORD val, const char *subKey, const char *name);
#define ThawDWORD(val) val = ThawDWORDF(val, FREEZE_SUBKEY, #val)
DWORD ThawDWORDF(DWORD val, char *subKey, char *name);
DWORD ThawDWORDF(DWORD val, const char *subKey, const char *name);
#define FreezeString(val) FreezeStringF(val, FREEZE_SUBKEY, #val)
void FreezeStringF(char *val, char *subKey, char *name);
void FreezeStringF(const char *val, const char *subKey, const char *name);
#define ThawString(val, max) ThawStringF(val, max, FREEZE_SUBKEY, #val)
void ThawStringF(char *val, int max, char *subKey, char *name);
void ThawStringF(char *val, int max, const char *subKey, const char *name);
#endif

View File

@ -63,7 +63,7 @@ SiHdl SpaceNavigator = SI_NO_HANDLE;
HWND MessageWnd, OkButton;
BOOL MessageDone;
char *MessageString;
const char *MessageString;
static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam)
@ -126,7 +126,7 @@ HWND CreateWindowClient(DWORD exStyle, char *className, char *windowName,
return h;
}
void DoMessageBox(char *str, int rows, int cols, BOOL error)
void DoMessageBox(const char *str, int rows, int cols, BOOL error)
{
EnableWindow(GraphicsWnd, FALSE);
EnableWindow(TextWnd, FALSE);
@ -194,7 +194,7 @@ void DoMessageBox(char *str, int rows, int cols, BOOL error)
DestroyWindow(MessageWnd);
}
void AddContextMenuItem(char *label, int id)
void AddContextMenuItem(const char *label, int id)
{
if(!ContextMenu) ContextMenu = CreatePopupMenu();
@ -258,7 +258,7 @@ void GetTextWindowSize(int *w, int *h)
GetWindowSize(TextWnd, w, h);
}
void OpenWebsite(char *url) {
void OpenWebsite(const char *url) {
ShellExecute(GraphicsWnd, "open", url, NULL, NULL, SW_SHOWNORMAL);
}
@ -270,27 +270,27 @@ void ExitNow(void) {
// Helpers so that we can read/write registry keys from the platform-
// independent code.
//-----------------------------------------------------------------------------
void CnfFreezeString(char *str, char *name)
void CnfFreezeString(const char *str, const char *name)
{ FreezeStringF(str, FREEZE_SUBKEY, name); }
void CnfFreezeDWORD(DWORD v, char *name)
void CnfFreezeDWORD(DWORD v, const char *name)
{ FreezeDWORDF(v, FREEZE_SUBKEY, name); }
void CnfFreezeFloat(float v, char *name)
void CnfFreezeFloat(float v, const char *name)
{ FreezeDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name); }
void CnfThawString(char *str, int maxLen, char *name)
void CnfThawString(char *str, int maxLen, const char *name)
{ ThawStringF(str, maxLen, FREEZE_SUBKEY, name); }
DWORD CnfThawDWORD(DWORD v, char *name)
DWORD CnfThawDWORD(DWORD v, const char *name)
{ return ThawDWORDF(v, FREEZE_SUBKEY, name); }
float CnfThawFloat(float v, char *name) {
float CnfThawFloat(float v, const char *name) {
DWORD d = ThawDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name);
return *((float *)&d);
}
void SetWindowTitle(char *str) {
void SetWindowTitle(const char *str) {
SetWindowText(GraphicsWnd, str);
}
@ -809,7 +809,7 @@ LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
//-----------------------------------------------------------------------------
// Common dialog routines, to open or save a file.
//-----------------------------------------------------------------------------
BOOL GetOpenFile(char *file, char *defExtension, char *selPattern)
BOOL GetOpenFile(char *file, const char *defExtension, const char *selPattern)
{
OPENFILENAME ofn;
@ -834,7 +834,7 @@ BOOL GetOpenFile(char *file, char *defExtension, char *selPattern)
return r;
}
BOOL GetSaveFile(char *file, char *defExtension, char *selPattern)
BOOL GetSaveFile(char *file, const char *defExtension, const char *selPattern)
{
OPENFILENAME ofn;

View File

@ -15,7 +15,7 @@
static HANDLE PermHeap, TempHeap;
void dbp(char *str, ...)
void dbp(const char *str, ...)
{
va_list f;
static char buf[1024*50];