Browse Source

* examples/cacaview.c:

+ Use sprintf() instead of snprintf() so that cacaview builds with DJGPP.
  * examples/aafire.c:
    + bzero the pixel buffer in the initialisation routine.
tags/v0.99.beta14
Sam Hocevar sam 21 years ago
parent
commit
e7b9d4bef4
2 changed files with 20 additions and 5 deletions
  1. +2
    -0
      examples/aafire.c
  2. +18
    -5
      examples/cacaview.c

+ 2
- 0
examples/aafire.c View File

@@ -29,6 +29,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "caca.h"

#define XSIZ (caca_get_width() * 2)
@@ -133,6 +134,7 @@ initialize (void)
caca_bitmap = caca_create_bitmap(8, XSIZ, YSIZ - 2, XSIZ, 0, 0, 0, 0);
caca_set_bitmap_palette(caca_bitmap, r, g, b, a);
bitmap = malloc(4 * caca_get_width() * caca_get_height() * sizeof(char));
memset(bitmap, 0, 4 * caca_get_width() * caca_get_height());
#else
aa_hidecursor (context);
#endif


+ 18
- 5
examples/cacaview.c View File

@@ -227,12 +227,18 @@ int main(int argc, char **argv)

if(items && reload)
{
char *buffer = malloc(ww + 1);
char *buffer;
int len = strlen(" Loading `%s'... ") + strlen(list[current]);

if(len < ww + 1)
len = ww + 1;

buffer = malloc(len);

/* Reset image-specific runtime variables */
zoom = 0;

snprintf(buffer, ww, " Loading `%s'... ", list[current]);
sprintf(buffer, " Loading `%s'... ", list[current]);
buffer[ww] = '\0';
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE);
caca_putstr((ww - strlen(buffer)) / 2, wh / 2, buffer);
@@ -261,8 +267,15 @@ int main(int argc, char **argv)
}
else if(!pixels)
{
char *buffer = malloc(ww + 1);
snprintf(buffer, ww, " Error loading `%s'. ", list[current]);
char *buffer;
int len = strlen(" Error loading `%s'. ") + strlen(list[current]);

if(len < ww + 1)
len = ww + 1;

buffer = malloc(len);

sprintf(buffer, " Error loading `%s'. ", list[current]);
buffer[ww] = '\0';
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE);
caca_putstr((ww - strlen(buffer)) / 2, wh / 2, buffer);
@@ -322,7 +335,7 @@ int main(int argc, char **argv)
caca_printf(ww - 14, wh - 2,
"(zoom: %s%i)", zoom > 0 ? "+" : "", zoom);

caca_set_color(CACA_COLOR_LIGHTRED, CACA_COLOR_BLACK);
caca_set_color(CACA_COLOR_LIGHTGRAY, CACA_COLOR_BLACK);
caca_draw_line(0, wh - 1, ww - 1, wh - 1, ' ');
switch(status)
{


Loading…
Cancel
Save