From 66315d5eea123eb1193aaa4e975fb7ce3901905c Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Mon, 16 Sep 2013 15:51:20 -0400 Subject: [PATCH] Added const qualifiers to edit-control string handling FLTK's Fl_Input widget, instantiated as {Graphics,Text}EditControl, returns a 'const char *' string. In order to handle this properly, several of SolveSpace's internal routines needed to gain a "const" qualifier on the edit-control string argument. --- clipboard.cpp | 2 +- confscreen.cpp | 2 +- expr.cpp | 4 ++-- expr.h | 4 ++-- mouse.cpp | 2 +- style.cpp | 2 +- textscreens.cpp | 2 +- ui.h | 12 ++++++------ view.cpp | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/clipboard.cpp b/clipboard.cpp index 0888d0e..0ade846 100644 --- a/clipboard.cpp +++ b/clipboard.cpp @@ -240,7 +240,7 @@ void GraphicsWindow::MenuClipboard(int id) { } } -bool TextWindow::EditControlDoneForPaste(char *s) { +bool TextWindow::EditControlDoneForPaste(const char *s) { Expr *e; switch(edit.meaning) { case EDIT_PASTE_TIMES_REPEATED: { diff --git a/confscreen.cpp b/confscreen.cpp index 433a12c..869c089 100644 --- a/confscreen.cpp +++ b/confscreen.cpp @@ -300,7 +300,7 @@ void TextWindow::ShowConfiguration(void) { Printf(false, " %Ft version %E%s", glGetString(GL_VERSION)); } -bool TextWindow::EditControlDoneForConfiguration(char *s) { +bool TextWindow::EditControlDoneForConfiguration(const char *s) { switch(edit.meaning) { case EDIT_LIGHT_INTENSITY: SS.lightIntensity[edit.i] = min(1, max(0, atof(s))); diff --git a/expr.cpp b/expr.cpp index 6e56f4f..1db17bd 100644 --- a/expr.cpp +++ b/expr.cpp @@ -714,7 +714,7 @@ void Expr::Parse(void) { PopOperator(); // discard the ALL_RESOLVED marker } -void Expr::Lex(char *in) { +void Expr::Lex(const char *in) { while(*in) { if(UnparsedCnt >= MAX_UNPARSED) throw "too long"; @@ -771,7 +771,7 @@ void Expr::Lex(char *in) { } } -Expr *Expr::From(char *in, bool popUpError) { +Expr *Expr::From(const char *in, bool popUpError) { UnparsedCnt = 0; UnparsedP = 0; OperandsP = 0; diff --git a/expr.h b/expr.h index 642bc97..fa9da83 100644 --- a/expr.h +++ b/expr.h @@ -113,8 +113,8 @@ public: Expr *DeepCopyWithParamsAsPointers(IdList *firstTry, IdList *thenTry); - static Expr *From(char *in, bool popUpError); - static void Lex(char *in); + static Expr *From(const char *in, bool popUpError); + static void Lex(const char *in); static Expr *Next(void); static void Consume(void); diff --git a/mouse.cpp b/mouse.cpp index ed7fbd5..753b3d6 100644 --- a/mouse.cpp +++ b/mouse.cpp @@ -1161,7 +1161,7 @@ void GraphicsWindow::MouseLeftDoubleClick(double mx, double my) { } } -void GraphicsWindow::EditControlDone(char *s) { +void GraphicsWindow::EditControlDone(const char *s) { HideGraphicsEditControl(); Constraint *c = SK.GetConstraint(constraintBeingEdited); diff --git a/style.cpp b/style.cpp index f1d33c3..a3754be 100644 --- a/style.cpp +++ b/style.cpp @@ -643,7 +643,7 @@ void TextWindow::ScreenChangeStyleYesNo(int link, DWORD v) { InvalidateGraphics(); } -bool TextWindow::EditControlDoneForStyles(char *str) { +bool TextWindow::EditControlDoneForStyles(const char *str) { Style *s; switch(edit.meaning) { case EDIT_STYLE_TEXT_HEIGHT: diff --git a/textscreens.cpp b/textscreens.cpp index a4cd760..6093f8c 100644 --- a/textscreens.cpp +++ b/textscreens.cpp @@ -611,7 +611,7 @@ void TextWindow::ShowTangentArc(void) { //----------------------------------------------------------------------------- // The edit control is visible, and the user just pressed enter. //----------------------------------------------------------------------------- -void TextWindow::EditControlDone(char *s) { +void TextWindow::EditControlDone(const char *s) { edit.showAgain = false; switch(edit.meaning) { diff --git a/ui.h b/ui.h index b29767d..b601836 100644 --- a/ui.h +++ b/ui.h @@ -317,11 +317,11 @@ public: static void ScreenChangeViewOrigin(int link, DWORD v); static void ScreenChangeViewProjection(int link, DWORD v); - bool EditControlDoneForStyles(char *s); - bool EditControlDoneForConfiguration(char *s); - bool EditControlDoneForPaste(char *s); - bool EditControlDoneForView(char *s); - void EditControlDone(char *s); + bool EditControlDoneForStyles(const char *s); + bool EditControlDoneForConfiguration(const char *s); + bool EditControlDoneForPaste(const char *s); + bool EditControlDoneForView(const char *s); + void EditControlDone(const char *s); }; class GraphicsWindow { @@ -679,7 +679,7 @@ public: void MouseScroll(double x, double y, int delta); void MouseLeave(void); bool KeyDown(int c); - void EditControlDone(char *s); + void EditControlDone(const char *s); SDWORD lastSpaceNavigatorTime; hGroup lastSpaceNavigatorGroup; diff --git a/view.cpp b/view.cpp index 58d96c2..58b355e 100644 --- a/view.cpp +++ b/view.cpp @@ -63,7 +63,7 @@ void TextWindow::ScreenChangeViewProjection(int link, DWORD v) { SS.TW.ShowEditControl(24, 10, buf); } -bool TextWindow::EditControlDoneForView(char *s) { +bool TextWindow::EditControlDoneForView(const char *s) { switch(edit.meaning) { case EDIT_VIEW_SCALE: { Expr *e = Expr::From(s, true);