Commit f425b8ce by András Bodor

clang warningok

A javítható clang warningok javítása, az egyre növekedő számú kikapcsolt
warningok helyett
parent 10de0ddb
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <iomanip> #include <iomanip>
#if defined(_WINX) #if defined(_WINX)
#include <conio.h> #include <conio.h>
#include <windows.h> #include <Windows.h>
#elif defined(_UNIX) #elif defined(_UNIX)
#include <termios.h> //termios, TCSANOW, ECHO, ICANON #include <termios.h> //termios, TCSANOW, ECHO, ICANON
#include <unistd.h> //STDIN_FILENO #include <unistd.h> //STDIN_FILENO
...@@ -29,7 +29,7 @@ void clrscr() { ...@@ -29,7 +29,7 @@ void clrscr() {
if (GetConsoleScreenBufferInfo(hstdout, &csbi)) { if (GetConsoleScreenBufferInfo(hstdout, &csbi)) {
COORD coordScreen = { 0, 0 }; COORD coordScreen = { 0, 0 };
DWORD cCharsWritten; DWORD cCharsWritten;
DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y; DWORD dwConSize = static_cast<DWORD>(csbi.dwSize.X) * static_cast<DWORD>(csbi.dwSize.Y);
FillConsoleOutputCharacter(hstdout, ' ', dwConSize, coordScreen, &cCharsWritten); FillConsoleOutputCharacter(hstdout, ' ', dwConSize, coordScreen, &cCharsWritten);
FillConsoleOutputAttribute(hstdout, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); FillConsoleOutputAttribute(hstdout, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hstdout, coordScreen); SetConsoleCursorPosition(hstdout, coordScreen);
...@@ -154,19 +154,9 @@ void Console::gotoxy(int x, int y) { ::gotoxy(x, y); } ...@@ -154,19 +154,9 @@ void Console::gotoxy(int x, int y) { ::gotoxy(x, y); }
void Console::hMeter(double value, double max, int width, const char *txt, int y, int x) { void Console::hMeter(double value, double max, int width, const char *txt, int y, int x) {
if (x > 0 || y > 0) gotoxy(x, y); if (x > 0 || y > 0) gotoxy(x, y);
if (txt != NULL) { if (txt != NULL) {
/// milyan hosszú lesz? /// A kiírást direkt a képernyőre írjuk, majd kihasználjuk, hogy
int len = snprintf(NULL, 0, txt, value)+1; /// printf return-je, hogy mennyi karaktert írt ki.
width -= printf(txt, value) + 1;
/// annyit foglalunk és beleírjuk
char *s = new char[len];
snprintf(s, len, txt, value);
std::cout << s;
/// kiírtuk, nem kell már a buffer
delete[] s;
/// ennyivel csökken a szélesség
width -= len;
} }
width -= 2; /// két szöglet miatt width -= 2; /// két szöglet miatt
double scale = value / max; double scale = value / max;
......
...@@ -60,6 +60,8 @@ int main() { ...@@ -60,6 +60,8 @@ int main() {
case Console::KEY_DOWN: case Console::KEY_DOWN:
--p; --p;
break; break;
default:
break;
} }
/// Kezelőszerv kijelzés a 3. sorba /// Kezelőszerv kijelzés a 3. sorba
con.hMeter(p.getPos(), 99, 80, "Pos%4.0f:", 3); con.hMeter(p.getPos(), 99, 80, "Pos%4.0f:", 3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment