improve linux makefile
[libpicofe.git] / common / menu.c
index e3c8cef..4d980fa 100644 (file)
@@ -94,12 +94,15 @@ void text_out16(int x, int y, const char *texto, ...)
        char    buffer[256];\r
        int     maxw = (SCREEN_WIDTH - x) / 8;\r
 \r
+       if (maxw < 0)\r
+               return;\r
+\r
        va_start(args, texto);\r
        vsnprintf(buffer, sizeof(buffer), texto, args);\r
        va_end(args);\r
 \r
-       if (maxw > 255)\r
-               maxw = 255;\r
+       if (maxw > sizeof(buffer) - 1)\r
+               maxw = sizeof(buffer) - 1;\r
        buffer[maxw] = 0;\r
 \r
        text_out16_(x,y,buffer,menu_text_color);\r
@@ -141,9 +144,15 @@ static void smalltext_out16_(int x, int y, const char *texto, int color)
 void smalltext_out16(int x, int y, const char *texto, int color)\r
 {\r
        char buffer[SCREEN_WIDTH/6+1];\r
+       int maxw = (SCREEN_WIDTH - x) / 6;\r
+\r
+       if (maxw < 0)\r
+               return;\r
 \r
        strncpy(buffer, texto, sizeof(buffer));\r
-       buffer[sizeof(buffer) - 1] = 0;\r
+       if (maxw > sizeof(buffer) - 1)\r
+               maxw = sizeof(buffer) - 1;\r
+       buffer[maxw] = 0;\r
 \r
        smalltext_out16_(x, y, buffer, color);\r
 }\r