math/gfreduce.[ch]: Fix out-of-bounds memory access.
[u/mdw/catacomb] / math / pgen-stdev.c
CommitLineData
d38c2e8d 1/* -*-c-*-
2 *
d38c2e8d 3 * Standard event handlers
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
45c0fd36 8/*----- Licensing notice --------------------------------------------------*
d38c2e8d 9 *
10 * This file is part of Catacomb.
11 *
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
45c0fd36 16 *
d38c2e8d 17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
45c0fd36 21 *
d38c2e8d 22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
26 */
27
d38c2e8d 28/*----- Header files ------------------------------------------------------*/
29
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33
34#include "pgen.h"
35
36/*----- Main code ---------------------------------------------------------*/
37
38/* --- @pgen_evspin@ --- *
39 *
40 * Displays a spinning baton to show progress.
41 */
42
43int pgen_evspin(int rq, pgen_event *ev, void *p)
44{
45 static char spinner[] = "/-\\|";
46 static char *q = spinner;
47
48 switch (rq) {
49 case PGEN_PASS:
50 case PGEN_FAIL:
d38c2e8d 51 putchar(*q++);
52 putchar('\b');
53 fflush(stdout);
54 if (!*q)
55 q = spinner;
56 break;
960547de 57 case PGEN_DONE:
58 case PGEN_ABORT:
59 putchar(' ');
60 putchar('\b');
61 fflush(stdout);
62 break;
d38c2e8d 63 }
64 return (0);
65}
66
67/* --- @pgen_ev@ --- *
68 *
69 * Traditional event handler, shows dots for each test.
70 */
71
72int pgen_ev(int rq, pgen_event *ev, void *p)
73{
74 switch (rq) {
75 case PGEN_BEGIN:
76 printf("Searching for %s: ", ev->name);
77 fflush(stdout);
78 break;
79 case PGEN_FAIL:
80 putchar('.');
81 fflush(stdout);
82 break;
83 case PGEN_PASS:
84 putchar('+');
85 fflush(stdout);
86 break;
87 case PGEN_DONE:
88 puts("+ ok");
89 break;
90 case PGEN_ABORT:
91 puts(" failed");
92 break;
93 }
94 return (0);
95}
96
df0292de 97/* --- @pgen_subev@ --- *
98 *
99 * Subsidiary event handler, mainly for Lim-Lee searches and so on.
100 */
101
102int pgen_subev(int rq, pgen_event *ev, void *p)
103{
104 switch (rq) {
105 case PGEN_BEGIN:
106 printf("[%s: ", ev->name);
107 fflush(stdout);
108 break;
109 case PGEN_FAIL:
110 putchar('.');
111 fflush(stdout);
112 break;
113 case PGEN_PASS:
114 putchar('+');
115 fflush(stdout);
116 break;
117 case PGEN_DONE:
118 fputs("+]", stdout);
119 fflush(stdout);
120 break;
121 case PGEN_ABORT:
122 fputs(" failed]", stdout);
123 fflush(stdout);
124 break;
125 }
126 return (0);
127}
128
d38c2e8d 129/*----- That's all, folks -------------------------------------------------*/