mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Mark many more function (and some objects) static
I noticed commit db3b531e2cab765a00475054d2e9046c9d0437d3 in the history where Simon added a bunch of "static" qualifiers. That suggested that consistently marking internal functions "static" is desirable, so I tried a build using GCC's -Wmissing-declarations, which requires prior declaration (presumed to be in a header file) of all global functions. This commit makes the GTK build clean under GCC's -Wmissing-declarations. I've also adding "static" to a few obviously internal objects, but GCC doesn't complain about those so I certainly haven't got them all.
This commit is contained in:
@ -930,7 +930,7 @@ struct parity_findloop_ctx {
|
|||||||
int i;
|
int i;
|
||||||
};
|
};
|
||||||
|
|
||||||
int parity_neighbour(int vertex, void *vctx)
|
static int parity_neighbour(int vertex, void *vctx)
|
||||||
{
|
{
|
||||||
struct parity_findloop_ctx *ctx = (struct parity_findloop_ctx *)vctx;
|
struct parity_findloop_ctx *ctx = (struct parity_findloop_ctx *)vctx;
|
||||||
struct solver_placement *p;
|
struct solver_placement *p;
|
||||||
|
106
gtk.c
106
gtk.c
@ -319,7 +319,7 @@ void frontend_default_colour(frontend *fe, float *output)
|
|||||||
output[0] = output[1] = output[2] = 0.9F;
|
output[0] = output[1] = output[2] = 0.9F;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_status_bar(void *handle, const char *text)
|
static void gtk_status_bar(void *handle, const char *text)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
|
|
||||||
@ -1154,7 +1154,7 @@ static void align_and_draw_text(int index, int align, int x, int y,
|
|||||||
* The exported drawing functions.
|
* The exported drawing functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void gtk_start_draw(void *handle)
|
static void gtk_start_draw(void *handle)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
fe->bbox_l = fe->w;
|
fe->bbox_l = fe->w;
|
||||||
@ -1164,20 +1164,21 @@ void gtk_start_draw(void *handle)
|
|||||||
setup_drawing(fe);
|
setup_drawing(fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_clip(void *handle, int x, int y, int w, int h)
|
static void gtk_clip(void *handle, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
do_clip(fe, x, y, w, h);
|
do_clip(fe, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_unclip(void *handle)
|
static void gtk_unclip(void *handle)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
do_unclip(fe);
|
do_unclip(fe);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_draw_text(void *handle, int x, int y, int fonttype, int fontsize,
|
static void gtk_draw_text(void *handle, int x, int y, int fonttype,
|
||||||
int align, int colour, const char *text)
|
int fontsize, int align, int colour,
|
||||||
|
const char *text)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
int i;
|
int i;
|
||||||
@ -1209,43 +1210,45 @@ void gtk_draw_text(void *handle, int x, int y, int fonttype, int fontsize,
|
|||||||
align_and_draw_text(fe, i, align, x, y, text);
|
align_and_draw_text(fe, i, align, x, y, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_draw_rect(void *handle, int x, int y, int w, int h, int colour)
|
static void gtk_draw_rect(void *handle, int x, int y, int w, int h, int colour)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
fe->dr_api->set_colour(fe, colour);
|
fe->dr_api->set_colour(fe, colour);
|
||||||
do_draw_rect(fe, x, y, w, h);
|
do_draw_rect(fe, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_draw_line(void *handle, int x1, int y1, int x2, int y2, int colour)
|
static void gtk_draw_line(void *handle, int x1, int y1, int x2, int y2,
|
||||||
|
int colour)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
fe->dr_api->set_colour(fe, colour);
|
fe->dr_api->set_colour(fe, colour);
|
||||||
do_draw_line(fe, x1, y1, x2, y2);
|
do_draw_line(fe, x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_draw_thick_line(void *handle, float thickness,
|
static void gtk_draw_thick_line(void *handle, float thickness,
|
||||||
float x1, float y1, float x2, float y2, int colour)
|
float x1, float y1, float x2, float y2,
|
||||||
|
int colour)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
fe->dr_api->set_colour(fe, colour);
|
fe->dr_api->set_colour(fe, colour);
|
||||||
do_draw_thick_line(fe, thickness, x1, y1, x2, y2);
|
do_draw_thick_line(fe, thickness, x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_draw_poly(void *handle, const int *coords, int npoints,
|
static void gtk_draw_poly(void *handle, const int *coords, int npoints,
|
||||||
int fillcolour, int outlinecolour)
|
int fillcolour, int outlinecolour)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
do_draw_poly(fe, coords, npoints, fillcolour, outlinecolour);
|
do_draw_poly(fe, coords, npoints, fillcolour, outlinecolour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_draw_circle(void *handle, int cx, int cy, int radius,
|
static void gtk_draw_circle(void *handle, int cx, int cy, int radius,
|
||||||
int fillcolour, int outlinecolour)
|
int fillcolour, int outlinecolour)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
do_draw_circle(fe, cx, cy, radius, fillcolour, outlinecolour);
|
do_draw_circle(fe, cx, cy, radius, fillcolour, outlinecolour);
|
||||||
}
|
}
|
||||||
|
|
||||||
blitter *gtk_blitter_new(void *handle, int w, int h)
|
static blitter *gtk_blitter_new(void *handle, int w, int h)
|
||||||
{
|
{
|
||||||
blitter *bl = snew(blitter);
|
blitter *bl = snew(blitter);
|
||||||
setup_blitter(bl, w, h);
|
setup_blitter(bl, w, h);
|
||||||
@ -1254,13 +1257,13 @@ blitter *gtk_blitter_new(void *handle, int w, int h)
|
|||||||
return bl;
|
return bl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_blitter_free(void *handle, blitter *bl)
|
static void gtk_blitter_free(void *handle, blitter *bl)
|
||||||
{
|
{
|
||||||
teardown_blitter(bl);
|
teardown_blitter(bl);
|
||||||
sfree(bl);
|
sfree(bl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_blitter_save(void *handle, blitter *bl, int x, int y)
|
static void gtk_blitter_save(void *handle, blitter *bl, int x, int y)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
do_blitter_save(fe, bl, x, y);
|
do_blitter_save(fe, bl, x, y);
|
||||||
@ -1268,7 +1271,7 @@ void gtk_blitter_save(void *handle, blitter *bl, int x, int y)
|
|||||||
bl->y = y;
|
bl->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_blitter_load(void *handle, blitter *bl, int x, int y)
|
static void gtk_blitter_load(void *handle, blitter *bl, int x, int y)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
if (x == BLITTER_FROMSAVED && y == BLITTER_FROMSAVED) {
|
if (x == BLITTER_FROMSAVED && y == BLITTER_FROMSAVED) {
|
||||||
@ -1278,7 +1281,7 @@ void gtk_blitter_load(void *handle, blitter *bl, int x, int y)
|
|||||||
do_blitter_load(fe, bl, x, y);
|
do_blitter_load(fe, bl, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_draw_update(void *handle, int x, int y, int w, int h)
|
static void gtk_draw_update(void *handle, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
if (fe->bbox_l > x ) fe->bbox_l = x ;
|
if (fe->bbox_l > x ) fe->bbox_l = x ;
|
||||||
@ -1287,7 +1290,7 @@ void gtk_draw_update(void *handle, int x, int y, int w, int h)
|
|||||||
if (fe->bbox_d < y+h) fe->bbox_d = y+h;
|
if (fe->bbox_d < y+h) fe->bbox_d = y+h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_end_draw(void *handle)
|
static void gtk_end_draw(void *handle)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
|
|
||||||
@ -1311,7 +1314,8 @@ void gtk_end_draw(void *handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_PANGO
|
#ifdef USE_PANGO
|
||||||
char *gtk_text_fallback(void *handle, const char *const *strings, int nstrings)
|
static char *gtk_text_fallback(void *handle, const char *const *strings,
|
||||||
|
int nstrings)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We assume Pango can cope with any UTF-8 likely to be emitted
|
* We assume Pango can cope with any UTF-8 likely to be emitted
|
||||||
@ -1322,18 +1326,18 @@ char *gtk_text_fallback(void *handle, const char *const *strings, int nstrings)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_PRINTING
|
#ifdef USE_PRINTING
|
||||||
void gtk_begin_doc(void *handle, int pages)
|
static void gtk_begin_doc(void *handle, int pages)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
gtk_print_operation_set_n_pages(fe->printop, pages);
|
gtk_print_operation_set_n_pages(fe->printop, pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_begin_page(void *handle, int number)
|
static void gtk_begin_page(void *handle, int number)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_begin_puzzle(void *handle, float xm, float xc,
|
static void gtk_begin_puzzle(void *handle, float xm, float xc,
|
||||||
float ym, float yc, int pw, int ph, float wmm)
|
float ym, float yc, int pw, int ph, float wmm)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
double ppw, pph, pox, poy, dpmmx, dpmmy;
|
double ppw, pph, pox, poy, dpmmx, dpmmy;
|
||||||
@ -1371,27 +1375,27 @@ void gtk_begin_puzzle(void *handle, float xm, float xc,
|
|||||||
fe->hatchspace = 1.0 * pw / wmm;
|
fe->hatchspace = 1.0 * pw / wmm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_end_puzzle(void *handle)
|
static void gtk_end_puzzle(void *handle)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
cairo_restore(fe->cr);
|
cairo_restore(fe->cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_end_page(void *handle, int number)
|
static void gtk_end_page(void *handle, int number)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_end_doc(void *handle)
|
static void gtk_end_doc(void *handle)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_line_width(void *handle, float width)
|
static void gtk_line_width(void *handle, float width)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
cairo_set_line_width(fe->cr, width);
|
cairo_set_line_width(fe->cr, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gtk_line_dotted(void *handle, bool dotted)
|
static void gtk_line_dotted(void *handle, bool dotted)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
|
|
||||||
@ -1404,7 +1408,7 @@ void gtk_line_dotted(void *handle, bool dotted)
|
|||||||
}
|
}
|
||||||
#endif /* USE_PRINTING */
|
#endif /* USE_PRINTING */
|
||||||
|
|
||||||
const struct internal_drawing_api internal_drawing = {
|
static const struct internal_drawing_api internal_drawing = {
|
||||||
draw_set_colour,
|
draw_set_colour,
|
||||||
#ifdef USE_CAIRO
|
#ifdef USE_CAIRO
|
||||||
do_draw_fill,
|
do_draw_fill,
|
||||||
@ -1413,14 +1417,14 @@ const struct internal_drawing_api internal_drawing = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_CAIRO
|
#ifdef USE_CAIRO
|
||||||
const struct internal_drawing_api internal_printing = {
|
static const struct internal_drawing_api internal_printing = {
|
||||||
print_set_colour,
|
print_set_colour,
|
||||||
do_print_fill,
|
do_print_fill,
|
||||||
do_print_fill_preserve,
|
do_print_fill_preserve,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const struct drawing_api gtk_drawing = {
|
static const struct drawing_api gtk_drawing = {
|
||||||
gtk_draw_text,
|
gtk_draw_text,
|
||||||
gtk_draw_rect,
|
gtk_draw_rect,
|
||||||
gtk_draw_line,
|
gtk_draw_line,
|
||||||
@ -1798,8 +1802,8 @@ static void align_label(GtkLabel *label, double x, double y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
bool message_box(GtkWidget *parent, const char *title, const char *msg,
|
static bool message_box(GtkWidget *parent, const char *title, const char *msg,
|
||||||
bool centre, int type)
|
bool centre, int type)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
gint ret;
|
gint ret;
|
||||||
@ -1893,7 +1897,7 @@ bool message_box(GtkWidget *parent, const char *title, const char *msg,
|
|||||||
}
|
}
|
||||||
#endif /* GTK_CHECK_VERSION(3,0,0) */
|
#endif /* GTK_CHECK_VERSION(3,0,0) */
|
||||||
|
|
||||||
void error_box(GtkWidget *parent, const char *msg)
|
static void error_box(GtkWidget *parent, const char *msg)
|
||||||
{
|
{
|
||||||
message_box(parent, "Error", msg, false, MB_OK);
|
message_box(parent, "Error", msg, false, MB_OK);
|
||||||
}
|
}
|
||||||
@ -2414,7 +2418,7 @@ static void set_selection(frontend *fe, GdkAtom selection)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_clip(frontend *fe, char *data)
|
static void write_clip(frontend *fe, char *data)
|
||||||
{
|
{
|
||||||
if (fe->paste_data)
|
if (fe->paste_data)
|
||||||
sfree(fe->paste_data);
|
sfree(fe->paste_data);
|
||||||
@ -2426,16 +2430,16 @@ void write_clip(frontend *fe, char *data)
|
|||||||
set_selection(fe, GDK_SELECTION_CLIPBOARD);
|
set_selection(fe, GDK_SELECTION_CLIPBOARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
|
static void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
|
||||||
guint info, guint time_stamp, gpointer data)
|
guint info, guint time_stamp, gpointer data)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)data;
|
frontend *fe = (frontend *)data;
|
||||||
gtk_selection_data_set(seldata, gtk_selection_data_get_target(seldata), 8,
|
gtk_selection_data_set(seldata, gtk_selection_data_get_target(seldata), 8,
|
||||||
fe->paste_data, fe->paste_data_len);
|
fe->paste_data, fe->paste_data_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
|
static gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)data;
|
frontend *fe = (frontend *)data;
|
||||||
|
|
||||||
@ -2533,7 +2537,7 @@ static char *file_selector(frontend *fe, const char *title, bool save)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_PRINTING
|
#ifdef USE_PRINTING
|
||||||
GObject *create_print_widget(GtkPrintOperation *print, gpointer data)
|
static GObject *create_print_widget(GtkPrintOperation *print, gpointer data)
|
||||||
{
|
{
|
||||||
GtkLabel *count_label, *width_label, *height_label,
|
GtkLabel *count_label, *width_label, *height_label,
|
||||||
*scale_llabel, *scale_rlabel;
|
*scale_llabel, *scale_rlabel;
|
||||||
@ -2674,8 +2678,8 @@ GObject *create_print_widget(GtkPrintOperation *print, gpointer data)
|
|||||||
return G_OBJECT(grid);
|
return G_OBJECT(grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_print_widget(GtkPrintOperation *print,
|
static void apply_print_widget(GtkPrintOperation *print,
|
||||||
GtkWidget *widget, gpointer data)
|
GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)data;
|
frontend *fe = (frontend *)data;
|
||||||
|
|
||||||
@ -2698,8 +2702,8 @@ void apply_print_widget(GtkPrintOperation *print,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_begin(GtkPrintOperation *printop,
|
static void print_begin(GtkPrintOperation *printop,
|
||||||
GtkPrintContext *context, gpointer data)
|
GtkPrintContext *context, gpointer data)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)data;
|
frontend *fe = (frontend *)data;
|
||||||
midend *nme = NULL; /* non-interactive midend for bulk puzzle generation */
|
midend *nme = NULL; /* non-interactive midend for bulk puzzle generation */
|
||||||
@ -2750,16 +2754,16 @@ void print_begin(GtkPrintOperation *printop,
|
|||||||
document_begin(fe->doc, fe->print_dr);
|
document_begin(fe->doc, fe->print_dr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_page(GtkPrintOperation *printop,
|
static void draw_page(GtkPrintOperation *printop,
|
||||||
GtkPrintContext *context,
|
GtkPrintContext *context,
|
||||||
gint page_nr, gpointer data)
|
gint page_nr, gpointer data)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)data;
|
frontend *fe = (frontend *)data;
|
||||||
document_print_page(fe->doc, fe->print_dr, page_nr);
|
document_print_page(fe->doc, fe->print_dr, page_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_end(GtkPrintOperation *printop,
|
static void print_end(GtkPrintOperation *printop,
|
||||||
GtkPrintContext *context, gpointer data)
|
GtkPrintContext *context, gpointer data)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)data;
|
frontend *fe = (frontend *)data;
|
||||||
|
|
||||||
|
4
latin.c
4
latin.c
@ -1352,7 +1352,7 @@ static void gen(int order, random_state *rs, int debug)
|
|||||||
sfree(sq);
|
sfree(sq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_soak(int order, random_state *rs)
|
static void test_soak(int order, random_state *rs)
|
||||||
{
|
{
|
||||||
digit *sq;
|
digit *sq;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -1375,7 +1375,7 @@ void test_soak(int order, random_state *rs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage_exit(const char *msg)
|
static void usage_exit(const char *msg)
|
||||||
{
|
{
|
||||||
if (msg)
|
if (msg)
|
||||||
fprintf(stderr, "%s: %s\n", quis, msg);
|
fprintf(stderr, "%s: %s\n", quis, msg);
|
||||||
|
@ -2492,11 +2492,11 @@ const struct game thegame = {
|
|||||||
const char *quis = NULL;
|
const char *quis = NULL;
|
||||||
bool csv = false;
|
bool csv = false;
|
||||||
|
|
||||||
void usage(FILE *out) {
|
static void usage(FILE *out) {
|
||||||
fprintf(out, "usage: %s [-v] [--print] <params>|<game id>\n", quis);
|
fprintf(out, "usage: %s [-v] [--print] <params>|<game id>\n", quis);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doprint(game_state *state)
|
static void doprint(game_state *state)
|
||||||
{
|
{
|
||||||
char *fmt = game_text_format(state);
|
char *fmt = game_text_format(state);
|
||||||
printf("%s", fmt);
|
printf("%s", fmt);
|
||||||
|
26
matching.c
26
matching.c
@ -368,13 +368,13 @@ static void matching_witness(void *scratchv, int nl, int nr, int *witness)
|
|||||||
|
|
||||||
#include "tree234.h"
|
#include "tree234.h"
|
||||||
|
|
||||||
int nl, nr, count;
|
static int nl, nr, count;
|
||||||
int **adjlists, *adjsizes;
|
static int **adjlists, *adjsizes;
|
||||||
int *adjdata, *outl, *outr, *witness;
|
static int *adjdata, *outl, *outr, *witness;
|
||||||
void *scratch;
|
static void *scratch;
|
||||||
random_state *rs;
|
static random_state *rs;
|
||||||
|
|
||||||
void allocate(int nl_, int nr_, int maxedges)
|
static void allocate(int nl_, int nr_, int maxedges)
|
||||||
{
|
{
|
||||||
nl = nl_;
|
nl = nl_;
|
||||||
nr = nr_;
|
nr = nr_;
|
||||||
@ -387,7 +387,7 @@ void allocate(int nl_, int nr_, int maxedges)
|
|||||||
scratch = smalloc(matching_scratch_size(nl, nr));
|
scratch = smalloc(matching_scratch_size(nl, nr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(void)
|
static void deallocate(void)
|
||||||
{
|
{
|
||||||
sfree(adjlists);
|
sfree(adjlists);
|
||||||
sfree(adjsizes);
|
sfree(adjsizes);
|
||||||
@ -398,7 +398,7 @@ void deallocate(void)
|
|||||||
sfree(scratch);
|
sfree(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_and_check_matching(void)
|
static void find_and_check_matching(void)
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
@ -454,14 +454,14 @@ struct nodename {
|
|||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
int compare_nodes(void *av, void *bv)
|
static int compare_nodes(void *av, void *bv)
|
||||||
{
|
{
|
||||||
const struct nodename *a = (const struct nodename *)av;
|
const struct nodename *a = (const struct nodename *)av;
|
||||||
const struct nodename *b = (const struct nodename *)bv;
|
const struct nodename *b = (const struct nodename *)bv;
|
||||||
return strcmp(a->name, b->name);
|
return strcmp(a->name, b->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int node_index(tree234 *n2i, tree234 *i2n, const char *name)
|
static int node_index(tree234 *n2i, tree234 *i2n, const char *name)
|
||||||
{
|
{
|
||||||
struct nodename *nn, *nn_prev;
|
struct nodename *nn, *nn_prev;
|
||||||
char *namedup = dupstr(name);
|
char *namedup = dupstr(name);
|
||||||
@ -485,7 +485,7 @@ struct edge {
|
|||||||
int L, R;
|
int L, R;
|
||||||
};
|
};
|
||||||
|
|
||||||
int compare_edges(void *av, void *bv)
|
static int compare_edges(void *av, void *bv)
|
||||||
{
|
{
|
||||||
const struct edge *a = (const struct edge *)av;
|
const struct edge *a = (const struct edge *)av;
|
||||||
const struct edge *b = (const struct edge *)bv;
|
const struct edge *b = (const struct edge *)bv;
|
||||||
@ -496,7 +496,7 @@ int compare_edges(void *av, void *bv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matching_from_user_input(FILE *fp, const char *filename)
|
static void matching_from_user_input(FILE *fp, const char *filename)
|
||||||
{
|
{
|
||||||
tree234 *Ln2i, *Li2n, *Rn2i, *Ri2n, *edges;
|
tree234 *Ln2i, *Li2n, *Rn2i, *Ri2n, *edges;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
@ -576,7 +576,7 @@ void matching_from_user_input(FILE *fp, const char *filename)
|
|||||||
deallocate();
|
deallocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_subsets(void)
|
static void test_subsets(void)
|
||||||
{
|
{
|
||||||
int b = 8;
|
int b = 8;
|
||||||
int n = 1 << b;
|
int n = 1 << b;
|
||||||
|
@ -512,7 +512,7 @@ void penrose_calculate_size(int which, int tilesize, int w, int h,
|
|||||||
int show_recursion = 0;
|
int show_recursion = 0;
|
||||||
int ntiles, nfinal;
|
int ntiles, nfinal;
|
||||||
|
|
||||||
int test_cb(penrose_state *state, vector *vs, int n, int depth)
|
static int test_cb(penrose_state *state, vector *vs, int n, int depth)
|
||||||
{
|
{
|
||||||
int i, xoff = 0, yoff = 0;
|
int i, xoff = 0, yoff = 0;
|
||||||
double l = penrose_side_length(state->start_size, depth);
|
double l = penrose_side_length(state->start_size, depth);
|
||||||
@ -542,7 +542,7 @@ int test_cb(penrose_state *state, vector *vs, int n, int depth)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage_exit(void)
|
static void usage_exit(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: penrose-test [--recursion] P2|P3 SIZE DEPTH\n");
|
fprintf(stderr, "Usage: penrose-test [--recursion] P2|P3 SIZE DEPTH\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -2321,7 +2321,7 @@ const struct game thegame = {
|
|||||||
const char *quis = NULL;
|
const char *quis = NULL;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
|
||||||
void usage(FILE *out) {
|
static void usage(FILE *out) {
|
||||||
fprintf(out, "usage: %s [--stdin] [--soak] [--seed SEED] <params>|<game id>\n", quis);
|
fprintf(out, "usage: %s [--stdin] [--soak] [--seed SEED] <params>|<game id>\n", quis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
sort.c
4
sort.c
@ -93,14 +93,14 @@ void arraysort_fn(void *array, size_t nmemb, size_t size,
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
int testcmp(const void *av, const void *bv, void *ctx)
|
static int testcmp(const void *av, const void *bv, void *ctx)
|
||||||
{
|
{
|
||||||
int a = *(const int *)av, b = *(const int *)bv;
|
int a = *(const int *)av, b = *(const int *)bv;
|
||||||
const int *keys = (const int *)ctx;
|
const int *keys = (const int *)ctx;
|
||||||
return keys[a] < keys[b] ? -1 : keys[a] > keys[b] ? +1 : 0;
|
return keys[a] < keys[b] ? -1 : keys[a] > keys[b] ? +1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int resetcmp(const void *av, const void *bv)
|
static int resetcmp(const void *av, const void *bv)
|
||||||
{
|
{
|
||||||
int a = *(const int *)av, b = *(const int *)bv;
|
int a = *(const int *)av, b = *(const int *)bv;
|
||||||
return a < b ? -1 : a > b ? +1 : 0;
|
return a < b ? -1 : a > b ? +1 : 0;
|
||||||
|
36
tree234.c
36
tree234.c
@ -1491,7 +1491,7 @@ tree234 *copytree234(tree234 *t, copyfn234 copyfn, void *copyfnstate) {
|
|||||||
/*
|
/*
|
||||||
* Error reporting function.
|
* Error reporting function.
|
||||||
*/
|
*/
|
||||||
void error(const char *fmt, ...) {
|
static void error(const char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
printf("ERROR: ");
|
printf("ERROR: ");
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
@ -1517,7 +1517,7 @@ typedef struct {
|
|||||||
char **levels;
|
char **levels;
|
||||||
} dispctx;
|
} dispctx;
|
||||||
|
|
||||||
int dispnode(node234 *n, int level, dispctx *ctx) {
|
static int dispnode(node234 *n, int level, dispctx *ctx) {
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
int xpos = strlen(ctx->levels[0]);
|
int xpos = strlen(ctx->levels[0]);
|
||||||
int len;
|
int len;
|
||||||
@ -1614,7 +1614,7 @@ int dispnode(node234 *n, int level, dispctx *ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void disptree(tree234 *t) {
|
static void disptree(tree234 *t) {
|
||||||
dispctx ctx;
|
dispctx ctx;
|
||||||
char *leveldata;
|
char *leveldata;
|
||||||
int width = count234(t);
|
int width = count234(t);
|
||||||
@ -1646,8 +1646,8 @@ typedef struct {
|
|||||||
int elemcount;
|
int elemcount;
|
||||||
} chkctx;
|
} chkctx;
|
||||||
|
|
||||||
int chknode(chkctx *ctx, int level, node234 *node,
|
static int chknode(chkctx *ctx, int level, node234 *node,
|
||||||
void *lowbound, void *highbound) {
|
void *lowbound, void *highbound) {
|
||||||
int nkids, nelems;
|
int nkids, nelems;
|
||||||
int i;
|
int i;
|
||||||
int count;
|
int count;
|
||||||
@ -1756,7 +1756,7 @@ int chknode(chkctx *ctx, int level, node234 *node,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void verifytree(tree234 *tree, void **array, int arraylen) {
|
static void verifytree(tree234 *tree, void **array, int arraylen) {
|
||||||
chkctx ctx;
|
chkctx ctx;
|
||||||
int i;
|
int i;
|
||||||
void *p;
|
void *p;
|
||||||
@ -1795,9 +1795,9 @@ void verifytree(tree234 *tree, void **array, int arraylen) {
|
|||||||
ctx.elemcount, i);
|
ctx.elemcount, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void verify(void) { verifytree(tree, array, arraylen); }
|
static void verify(void) { verifytree(tree, array, arraylen); }
|
||||||
|
|
||||||
void internal_addtest(void *elem, int index, void *realret) {
|
static void internal_addtest(void *elem, int index, void *realret) {
|
||||||
int i, j;
|
int i, j;
|
||||||
void *retval;
|
void *retval;
|
||||||
|
|
||||||
@ -1822,7 +1822,7 @@ void internal_addtest(void *elem, int index, void *realret) {
|
|||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addtest(void *elem) {
|
static void addtest(void *elem) {
|
||||||
int i;
|
int i;
|
||||||
void *realret;
|
void *realret;
|
||||||
|
|
||||||
@ -1840,7 +1840,7 @@ void addtest(void *elem) {
|
|||||||
internal_addtest(elem, i, realret);
|
internal_addtest(elem, i, realret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addpostest(void *elem, int i) {
|
static void addpostest(void *elem, int i) {
|
||||||
void *realret;
|
void *realret;
|
||||||
|
|
||||||
realret = addpos234(tree, elem, i);
|
realret = addpos234(tree, elem, i);
|
||||||
@ -1848,7 +1848,7 @@ void addpostest(void *elem, int i) {
|
|||||||
internal_addtest(elem, i, realret);
|
internal_addtest(elem, i, realret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delpostest(int i) {
|
static void delpostest(int i) {
|
||||||
int index = i;
|
int index = i;
|
||||||
void *elem = array[i], *ret;
|
void *elem = array[i], *ret;
|
||||||
|
|
||||||
@ -1871,7 +1871,7 @@ void delpostest(int i) {
|
|||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deltest(void *elem) {
|
static void deltest(void *elem) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -1890,19 +1890,19 @@ void deltest(void *elem) {
|
|||||||
* given in ANSI C99 draft N869. It assumes `unsigned' is 32 bits;
|
* given in ANSI C99 draft N869. It assumes `unsigned' is 32 bits;
|
||||||
* change it if not.
|
* change it if not.
|
||||||
*/
|
*/
|
||||||
int randomnumber(unsigned *seed) {
|
static int randomnumber(unsigned *seed) {
|
||||||
*seed *= 1103515245;
|
*seed *= 1103515245;
|
||||||
*seed += 12345;
|
*seed += 12345;
|
||||||
return ((*seed) / 65536) % 32768;
|
return ((*seed) / 65536) % 32768;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mycmp(void *av, void *bv) {
|
static int mycmp(void *av, void *bv) {
|
||||||
char const *a = (char const *)av;
|
char const *a = (char const *)av;
|
||||||
char const *b = (char const *)bv;
|
char const *b = (char const *)bv;
|
||||||
return strcmp(a, b);
|
return strcmp(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *const strings_init[] = {
|
static const char *const strings_init[] = {
|
||||||
"0", "2", "3", "I", "K", "d", "H", "J", "Q", "N", "n", "q", "j", "i",
|
"0", "2", "3", "I", "K", "d", "H", "J", "Q", "N", "n", "q", "j", "i",
|
||||||
"7", "G", "F", "D", "b", "x", "g", "B", "e", "v", "V", "T", "f", "E",
|
"7", "G", "F", "D", "b", "x", "g", "B", "e", "v", "V", "T", "f", "E",
|
||||||
"S", "8", "A", "k", "X", "p", "C", "R", "a", "o", "r", "O", "Z", "u",
|
"S", "8", "A", "k", "X", "p", "C", "R", "a", "o", "r", "O", "Z", "u",
|
||||||
@ -1924,9 +1924,9 @@ const char *const strings_init[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define NSTR lenof(strings_init)
|
#define NSTR lenof(strings_init)
|
||||||
char *strings[NSTR];
|
static char *strings[NSTR];
|
||||||
|
|
||||||
void findtest(void) {
|
static void findtest(void) {
|
||||||
static const int rels[] = {
|
static const int rels[] = {
|
||||||
REL234_EQ, REL234_GE, REL234_LE, REL234_LT, REL234_GT
|
REL234_EQ, REL234_GE, REL234_LE, REL234_LT, REL234_GT
|
||||||
};
|
};
|
||||||
@ -2015,7 +2015,7 @@ void findtest(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void splittest(tree234 *tree, void **array, int arraylen) {
|
static void splittest(tree234 *tree, void **array, int arraylen) {
|
||||||
int i;
|
int i;
|
||||||
tree234 *tree3, *tree4;
|
tree234 *tree3, *tree4;
|
||||||
for (i = 0; i <= arraylen; i++) {
|
for (i = 0; i <= arraylen; i++) {
|
||||||
|
@ -987,11 +987,11 @@ static void free_sets(struct sets *s)
|
|||||||
/*
|
/*
|
||||||
* Print a text formula for producing a given output.
|
* Print a text formula for producing a given output.
|
||||||
*/
|
*/
|
||||||
void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
|
static void print_recurse(struct sets *s, struct set *ss, int pathindex,
|
||||||
int priority, int assoc, int child);
|
int index, int priority, int assoc, int child);
|
||||||
void print_recurse_inner(struct sets *s, struct set *ss,
|
static void print_recurse_inner(struct sets *s, struct set *ss,
|
||||||
struct ancestor *a, int pathindex, int index,
|
struct ancestor *a, int pathindex, int index,
|
||||||
int priority, int assoc, int child)
|
int priority, int assoc, int child)
|
||||||
{
|
{
|
||||||
if (a->prev && index != a->pr) {
|
if (a->prev && index != a->pr) {
|
||||||
int pi;
|
int pi;
|
||||||
@ -1066,8 +1066,8 @@ void print_recurse_inner(struct sets *s, struct set *ss,
|
|||||||
printf("/%d", ss->numbers[2*index+1]);
|
printf("/%d", ss->numbers[2*index+1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
|
static void print_recurse(struct sets *s, struct set *ss, int pathindex,
|
||||||
int priority, int assoc, int child)
|
int index, int priority, int assoc, int child)
|
||||||
{
|
{
|
||||||
if (!ss->a.prev || pathindex < ss->a.prev->npaths) {
|
if (!ss->a.prev || pathindex < ss->a.prev->npaths) {
|
||||||
print_recurse_inner(s, ss, &ss->a, pathindex,
|
print_recurse_inner(s, ss, &ss->a, pathindex,
|
||||||
@ -1085,7 +1085,7 @@ void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void print(int pathindex, struct sets *s, struct output *o)
|
static void print(int pathindex, struct sets *s, struct output *o)
|
||||||
{
|
{
|
||||||
print_recurse(s, o->set, pathindex, o->index, 0, 0, 0);
|
print_recurse(s, o->set, pathindex, o->index, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ struct solver_scratch {
|
|||||||
int *tmp;
|
int *tmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct solver_scratch *solver_scratch_new(int w, int h, int k)
|
static struct solver_scratch *solver_scratch_new(int w, int h, int k)
|
||||||
{
|
{
|
||||||
int wh = w*h;
|
int wh = w*h;
|
||||||
struct solver_scratch *sc = snew(struct solver_scratch);
|
struct solver_scratch *sc = snew(struct solver_scratch);
|
||||||
@ -233,7 +233,7 @@ struct solver_scratch *solver_scratch_new(int w, int h, int k)
|
|||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void solver_scratch_free(struct solver_scratch *sc)
|
static void solver_scratch_free(struct solver_scratch *sc)
|
||||||
{
|
{
|
||||||
sfree(sc->dsf);
|
sfree(sc->dsf);
|
||||||
sfree(sc->size);
|
sfree(sc->size);
|
||||||
@ -243,7 +243,7 @@ void solver_scratch_free(struct solver_scratch *sc)
|
|||||||
sfree(sc);
|
sfree(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
|
static void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
|
||||||
{
|
{
|
||||||
int w = sc->w, h = sc->h, k = sc->k;
|
int w = sc->w, h = sc->h, k = sc->k;
|
||||||
int wh = w*h;
|
int wh = w*h;
|
||||||
@ -297,7 +297,7 @@ void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
|
|||||||
sc->disconnect[i*wh+yx2]);
|
sc->disconnect[i*wh+yx2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
|
static void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
|
||||||
{
|
{
|
||||||
int w = sc->w, h = sc->h;
|
int w = sc->w, h = sc->h;
|
||||||
int wh = w*h;
|
int wh = w*h;
|
||||||
@ -316,7 +316,7 @@ void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
|
|||||||
sc->disconnect[yx2*wh+yx1] = true;
|
sc->disconnect[yx2*wh+yx1] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void solver_init(struct solver_scratch *sc)
|
static void solver_init(struct solver_scratch *sc)
|
||||||
{
|
{
|
||||||
int w = sc->w, h = sc->h;
|
int w = sc->w, h = sc->h;
|
||||||
int wh = w*h;
|
int wh = w*h;
|
||||||
@ -332,8 +332,8 @@ void solver_init(struct solver_scratch *sc)
|
|||||||
memset(sc->disconnect, 0, wh*wh * sizeof(bool));
|
memset(sc->disconnect, 0, wh*wh * sizeof(bool));
|
||||||
}
|
}
|
||||||
|
|
||||||
int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
|
static int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
|
||||||
bool *gen_lock)
|
bool *gen_lock)
|
||||||
{
|
{
|
||||||
int w = sc->w, h = sc->h, k = sc->k;
|
int w = sc->w, h = sc->h, k = sc->k;
|
||||||
int wh = w*h;
|
int wh = w*h;
|
||||||
@ -492,7 +492,7 @@ int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *generate(int w, int h, int k, random_state *rs)
|
static unsigned char *generate(int w, int h, int k, random_state *rs)
|
||||||
{
|
{
|
||||||
int wh = w*h;
|
int wh = w*h;
|
||||||
int n = wh/k;
|
int n = wh/k;
|
||||||
|
@ -957,7 +957,7 @@ struct game_drawstate {
|
|||||||
* subfunction. move_type() returns -1 for an illegal move, 0 for a
|
* subfunction. move_type() returns -1 for an illegal move, 0 for a
|
||||||
* movement, and 1 for a push.
|
* movement, and 1 for a push.
|
||||||
*/
|
*/
|
||||||
int move_type(const game_state *state, int dx, int dy)
|
static int move_type(const game_state *state, int dx, int dy)
|
||||||
{
|
{
|
||||||
int w = state->p.w, h = state->p.h;
|
int w = state->p.w, h = state->p.h;
|
||||||
int px = state->px, py = state->py;
|
int px = state->px, py = state->py;
|
||||||
|
Reference in New Issue
Block a user