X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fechochar.c;h=8cb0833aa023b1e158dfb41b62ea2d5e143489e5;hp=9f2d11c5bb9476796ac87a67c2f43ba0e0cbd535;hb=67ab4b308e932639a3a832052228d445c41c54b4;hpb=027ae42953e3186daed8f3882da73de48291b606;ds=sidebyside diff --git a/test/echochar.c b/test/echochar.c index 9f2d11c5..8cb0833a 100644 --- a/test/echochar.c +++ b/test/echochar.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006 Free Software Foundation, Inc. * + * Copyright (c) 2006-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: echochar.c,v 1.3 2006/12/03 00:14:29 tom Exp $ + * $Id: echochar.c,v 1.9 2012/06/09 20:30:32 tom Exp $ * * Demonstrate the echochar function (compare to dots.c). * Thomas Dickey - 2006/11/4 @@ -49,7 +49,7 @@ cleanup(void) printf("\n\n%ld total chars, rate %.2f/sec\n", total_chars, - ((double) (total_chars) / (time((time_t *) 0) - started))); + ((double) (total_chars) / (double) (time((time_t *) 0) - started))); } static void @@ -58,11 +58,11 @@ onsig(int n GCC_UNUSED) interrupted = TRUE; } -static float +static double ranf(void) { long r = (rand() & 077777); - return ((float) r / 32768.); + return ((double) r / 32768.); } static void @@ -70,26 +70,27 @@ set_color(char *my_pairs, int fg, int bg) { int pair = (fg * COLORS) + bg; if (!my_pairs[pair]) { - init_pair(pair, fg, bg); + init_pair((short) pair, + (short) fg, + (short) bg); } - attron(COLOR_PAIR(pair)); + attron((attr_t) COLOR_PAIR(pair)); } int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) +main(int argc GCC_UNUSED, + char *argv[]GCC_UNUSED) { int ch, x, y, z, p; - float r; - float c; + double r; + double c; bool use_colors; bool opt_r = FALSE; char *my_pairs = 0; int last_fg = 0; int last_bg = 0; - while ((ch = getopt(argc, argv, "r")) != EOF) { + while ((ch = getopt(argc, argv, "r")) != -1) { switch (ch) { case 'r': opt_r = TRUE; @@ -107,7 +108,7 @@ main( if (use_colors) { start_color(); if (COLOR_PAIRS > 0) { - my_pairs = calloc(COLOR_PAIRS, sizeof(*my_pairs)); + my_pairs = typeCalloc(char, (size_t) COLOR_PAIRS); } use_colors = (my_pairs != 0); } @@ -116,8 +117,8 @@ main( curs_set(0); - r = (float) (LINES - 4); - c = (float) (COLS - 4); + r = (double) (LINES - 4); + c = (double) (COLS - 4); started = time((time_t *) 0); while (!interrupted) { @@ -146,10 +147,10 @@ main( } } if (opt_r) { - addch(p); + addch(UChar(p)); refresh(); } else { - echochar(p); + echochar(UChar(p)); } ++total_chars; }