From 66758b9595044c3fa412df488adae5aa93613782 Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Thu, 19 Sep 2013 02:35:56 -0400 Subject: [PATCH] Miscellaneous adjustments for warnings and code quality This commit contains a grab bag of minor changes not worth committing individually: * Replaced raw Latin-1 characters with octal escapes to avoid source-file encoding issues * Undefined some convenience macros after they've served their purpose * Rewrote SEdge::From() to avoid confusing less-capable C++ compilers * Have oops() print a newline at the end of its message * Removed "static" keyword from the Bernstein() function definition, as it has a non-static prototype in srf/surface.h * Added casts (and changed a variable type) to quell warnings about integer size and signedness * Simplified an expression with our handy arraylen() macro --- file.cpp | 2 +- group.cpp | 2 ++ polygon.cpp | 5 ++++- solvespace.h | 2 +- srf/ratpoly.cpp | 2 +- style.cpp | 2 +- textwin.cpp | 6 ++++-- win32/w32main.cpp | 2 +- 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/file.cpp b/file.cpp index c25b083..00fbb74 100644 --- a/file.cpp +++ b/file.cpp @@ -5,7 +5,7 @@ //----------------------------------------------------------------------------- #include "solvespace.h" -#define VERSION_STRING "±²³SolveSpaceREVa" +#define VERSION_STRING "\261\262\263" "SolveSpaceREVa" static int StrStartsWith(const char *str, const char *start) { return memcmp(str, start, strlen(start)) == 0; diff --git a/group.cpp b/group.cpp index 9fc16fa..cf6a0d7 100644 --- a/group.cpp +++ b/group.cpp @@ -513,6 +513,8 @@ void Group::GenerateEquations(IdList *l) { AddEq(l, (EC(axis.x))->Minus(EP(4)), 3); AddEq(l, (EC(axis.y))->Minus(EP(5)), 4); AddEq(l, (EC(axis.z))->Minus(EP(6)), 5); +#undef EC +#undef EP } else if(type == EXTRUDE) { if(predef.entityB.v != Entity::FREE_IN_3D.v) { // The extrusion path is locked along a line, normal to the diff --git a/polygon.cpp b/polygon.cpp index 3239a81..8816331 100644 --- a/polygon.cpp +++ b/polygon.cpp @@ -58,7 +58,10 @@ STriangle STriangle::From(STriMeta meta, Vector a, Vector b, Vector c) { } SEdge SEdge::From(Vector a, Vector b) { - SEdge se = { 0, 0, 0, a, b }; + SEdge se; + ZERO(&se); + se.a = a; + se.b = b; return se; } diff --git a/solvespace.h b/solvespace.h index 9a5c463..11fb378 100644 --- a/solvespace.h +++ b/solvespace.h @@ -8,7 +8,7 @@ #define __SOLVESPACE_H // Debugging functions -#define oops() do { dbp("oops at line %d, file %s", __LINE__, __FILE__); \ +#define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \ if(0) *(char *)0 = 1; exit(-1); } while(0) #ifndef min #define min(x, y) ((x) < (y) ? (x) : (y)) diff --git a/srf/ratpoly.cpp b/srf/ratpoly.cpp index d443719..bdc5882 100644 --- a/srf/ratpoly.cpp +++ b/srf/ratpoly.cpp @@ -13,7 +13,7 @@ // and convergence should be fast by now. #define RATPOLY_EPS (LENGTH_EPS/(1e2)) -static double Bernstein(int k, int deg, double t) +double Bernstein(int k, int deg, double t) { if(k > deg || k < 0) return 0; diff --git a/style.cpp b/style.cpp index c1908fa..73e3859 100644 --- a/style.cpp +++ b/style.cpp @@ -128,7 +128,7 @@ void Style::FreezeDefaultStyles(void) { DWORD Style::CreateCustomStyle(void) { SS.UndoRemember(); - DWORD vs = max(Style::FIRST_CUSTOM, SK.style.MaximumId() + 1); + DWORD vs = max((DWORD)Style::FIRST_CUSTOM, SK.style.MaximumId() + 1); hStyle hs = { vs }; (void)Style::Get(hs); return hs.v; diff --git a/textwin.cpp b/textwin.cpp index 34ed261..0c16169 100644 --- a/textwin.cpp +++ b/textwin.cpp @@ -130,7 +130,8 @@ void TextWindow::Printf(bool halfLine, const char *fmt, ...) { meta[r][c].link = NOT_A_LINK; } - int fg = 'd', bg = 'd'; + char fg = 'd'; + int bg = 'd'; int link = NOT_A_LINK; DWORD data = 0; LinkFunction *f = NULL, *h = NULL; @@ -211,7 +212,7 @@ void TextWindow::Printf(bool halfLine, const char *fmt, ...) { color = 0; } if(*fmt == 'F') { - fg = color; + fg = (char)color; } else { bg = color; } @@ -1002,6 +1003,7 @@ void TextWindow::MouseEvent(bool leftClick, bool leftDown, double x, double y) { SetMousePointerToHand(false); } } +#undef META done: if((!ps.Equals(&(SS.GW.hover))) || diff --git a/win32/w32main.cpp b/win32/w32main.cpp index 0729344..b64c10a 100644 --- a/win32/w32main.cpp +++ b/win32/w32main.cpp @@ -918,7 +918,7 @@ static void MenuById(int id, BOOL yes, BOOL check) if(SS.GW.menu[i].id == id) { if(subMenu < 0) oops(); - if(subMenu >= (sizeof(SubMenus)/sizeof(SubMenus[0]))) oops(); + if(subMenu >= arraylen(SubMenus)) oops(); if(check) { CheckMenuItem(SubMenus[subMenu], id,