diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-26 22:49:11 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-26 22:49:11 +0000 |
commit | b01f39a8e6eadd35758fe4301e019b66f238917d (patch) | |
tree | 82ffbfb4d920bed078bcd77ebea90f0f2c7ff26e | |
parent | 82a6e01af6c39e22855495b912c23efddfb17224 (diff) |
merge latest (4.3.99.16) from XFree86 (vendor) branchXORG-RELEASE-1-BASEXEVIE-MERGEXEVIE-BASEXINERAMA_2XEVIE
-rw-r--r-- | choice.c | 34 | ||||
-rw-r--r-- | dashlist.c | 28 | ||||
-rw-r--r-- | getfile.c | 20 | ||||
-rw-r--r-- | gram.y | 27 | ||||
-rw-r--r-- | interpret.c | 123 | ||||
-rw-r--r-- | main.c | 56 | ||||
-rw-r--r-- | planemask.c | 28 | ||||
-rw-r--r-- | record.c | 65 | ||||
-rw-r--r-- | testfrac.c | 35 | ||||
-rw-r--r-- | tests.c | 89 | ||||
-rw-r--r-- | text.c | 43 | ||||
-rw-r--r-- | xgc.h | 106 |
12 files changed, 267 insertions, 387 deletions
@@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/xgc/choice.c,v 1.3 2003/10/24 20:38:18 tsi Exp $ */ /* ** xgc ** @@ -15,14 +16,7 @@ #include "xgc.h" -static void print_text_to_buffer( -#if NeedFunctionPrototypes - Widget, caddr_t, caddr_t -#endif -); -extern void interpret(); - -extern XStuff X; +static void print_text_to_buffer(Widget, caddr_t, caddr_t); /* create_choice(w,info) ** --------------------- @@ -50,9 +44,7 @@ extern XStuff X; */ ChoiceDesc * -create_choice(w,info) - Widget w; - XgcStuff *info; +create_choice(Widget w, XgcStuff *info) { ChoiceDesc *choice; /* What we will return. Contains ** Widget ID's of the label and toggles. */ @@ -188,9 +180,7 @@ create_choice(w,info) */ void -select_button(choice,togglenum) - ChoiceDesc *choice; - int togglenum; +select_button(ChoiceDesc *choice, int togglenum) { static Arg toggleargs[] = { {XtNstate, (XtArgVal) True} @@ -207,9 +197,7 @@ select_button(choice,togglenum) */ void -line_up_labels(descs,numdescs) - ChoiceDesc *descs[]; - int numdescs; +line_up_labels(ChoiceDesc *descs[], int numdescs) { int i; /* counter */ Dimension width; /* current width */ @@ -246,9 +234,7 @@ line_up_labels(descs,numdescs) */ void -choose_defaults(descs,numdescs) - ChoiceDesc *descs[]; - int numdescs; +choose_defaults(ChoiceDesc *descs[], int numdescs) { int i; /* which choice layout */ int j; /* which toggle within it */ @@ -273,10 +259,10 @@ choose_defaults(descs,numdescs) /*ARGSUSED*/ static void -print_text_to_buffer(w,closure,call_data) - Widget w; - caddr_t closure; /* contains the string */ - caddr_t call_data; +print_text_to_buffer( + Widget w, + caddr_t closure, /* contains the string */ + caddr_t call_data) { interpret((char *) closure); /* Gee, that was easy */ } @@ -7,7 +7,7 @@ ** functions to create more than one of these dashlist choice things ** will fail in a big way. */ -/* $XFree86: xc/programs/xgc/dashlist.c,v 1.3 2001/07/29 21:23:21 tsi Exp $ */ +/* $XFree86: xc/programs/xgc/dashlist.c,v 1.4 2003/05/07 21:02:06 herrb Exp $ */ #include <stdio.h> #include <X11/Xos.h> @@ -19,14 +19,7 @@ #include <X11/Xaw/Toggle.h> #include "xgc.h" -static void change_dashlist( -#if NeedFunctionPrototypes - Widget, caddr_t, caddr_t -#endif -); -extern void interpret(); - -extern XStuff X; +static void change_dashlist(Widget, caddr_t, caddr_t); static short dashlist = 240; /* in binary, becomes the dashlist (240 = XXXX____) */ @@ -40,8 +33,7 @@ static Widget *dashes; /* the toggle widgets */ */ void -create_dashlist_choice(w) - Widget w; +create_dashlist_choice(Widget w) { /* callback list for the toggle widgets */ static XtCallbackRec callbacklist[] = { @@ -106,7 +98,7 @@ create_dashlist_choice(w) else dashargs[6].value = (XtArgVal) False; - sprintf(name,"dashlist%d",i); + snprintf(name, sizeof name, "dashlist%d",i); dashinfo[i] = i; /* which bit we're on; this is needed in change_dashlist (the callback) */ @@ -127,10 +119,7 @@ create_dashlist_choice(w) /*ARGSUSED*/ static void -change_dashlist(w,closure,call_data) - Widget w; - caddr_t closure; - caddr_t call_data; +change_dashlist(Widget w, caddr_t closure, caddr_t call_data) { int num; /* what number button it is */ Boolean on; /* is it currently on or off? */ @@ -156,8 +145,8 @@ change_dashlist(w,closure,call_data) } /* now tell interpret() about it */ - sprintf(buf,"dashlist %d\n",dashlist); - interpret(buf,FALSE); + snprintf(buf, sizeof buf, "dashlist %d\n",dashlist); + interpret(buf); } /* update_dashlist(newdash) @@ -167,8 +156,7 @@ change_dashlist(w,closure,call_data) */ void -update_dashlist(newdash) - int newdash; +update_dashlist(int newdash) { int i; /* counter */ static Arg dashargs[] = { /* Arglist for setting toggle state */ @@ -2,7 +2,7 @@ ** getfilename.c ** */ -/* $XFree86: xc/programs/xgc/getfile.c,v 1.3 2000/02/17 14:00:35 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/getfile.c,v 1.5 2003/05/27 22:27:06 tsi Exp $ */ #include <X11/Intrinsic.h> #include <X11/StringDefs.h> @@ -15,26 +15,22 @@ #include "xgc.h" -extern XStuff X; -extern Widget topform; static Widget popupshell = NULL; /* popup dialog box */ Widget filename_text_widget; /* Widget containing the name of the file the user has selected */ -extern XtAppContext appcontext; -static void kill_popup_shell(); +static void kill_popup_shell(void); void -get_filename(success,failure) - void (*success)(); /* what function to call when a filename is +get_filename( + void (*success)(void), /* what function to call when a filename is chosen */ - void (*failure)(); /* what function to call when the user + void (*failure)(void)) /* what function to call when the user cancels */ { static Widget popupform; /* form inside shell */ static Widget label; /* "Filename :" */ - static Widget cancel; /* command, select to cancel */ Window dummy1, dummy2; int x1,y1,x2,y2; @@ -138,8 +134,8 @@ get_filename(success,failure) cancelargs[0].value = (XtArgVal) filename_text_widget; cancelargs[1].value = (XtArgVal) cancelcallbacklist; - cancel = XtCreateManagedWidget("Cancel",commandWidgetClass,popupform, - cancelargs,XtNumber(cancelargs)); + (void) XtCreateManagedWidget("Cancel",commandWidgetClass,popupform, + cancelargs,XtNumber(cancelargs)); /* Bring up the popup. When the user presses cancel or the return key, ** the function kill_popup_shell (below) will be called to remove it. */ @@ -153,7 +149,7 @@ get_filename(success,failure) */ static void -kill_popup_shell() +kill_popup_shell(void) { XtPopdown(popupshell); } @@ -1,36 +1,18 @@ /* ** grammar for xgc syntax */ -/* $XFree86: xc/programs/xgc/gram.y,v 1.3 2000/02/17 14:00:36 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/gram.y,v 1.4 2003/05/07 21:02:07 herrb Exp $ */ %{ #define YYDEBUG 1 #include <stdio.h> #include <X11/X.h> -#include "constants.h" +#include <X11/Intrinsic.h> +#include "xgc.h" extern int yylineno; -extern FILE *yyin; -int yylex(); -void yyerror(); -extern void GC_change_function(); -extern void GC_change_foreground(); -extern void GC_change_background(); -extern void GC_change_linewidth(); -extern void GC_change_linestyle(); -extern void GC_change_capstyle(); -extern void GC_change_joinstyle(); -extern void GC_change_fillstyle(); -extern void GC_change_fillrule(); -extern void GC_change_arcmode(); -extern void GC_change_dashlist(); -extern void GC_change_planemask(); -extern void GC_change_font(); -extern void change_test(); -extern void change_percent(); -extern void run_test(); %} %union @@ -109,8 +91,7 @@ stmt : error %% void -yyerror(s) - const char *s; +yyerror(const char *s) { fprintf(stderr, "xgc: syntax error, line %d\n", yylineno); } diff --git a/interpret.c b/interpret.c index d12922b..ff77c47 100644 --- a/interpret.c +++ b/interpret.c @@ -3,7 +3,7 @@ ** ** interprets and executes lines in the Xgc syntax. */ -/* $XFree86: xc/programs/xgc/interpret.c,v 1.4 2002/01/07 20:38:30 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/interpret.c,v 1.5 2003/05/07 21:02:07 herrb Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -12,55 +12,6 @@ #include "xgc.h" #include "tile" -void change_text(); -void GC_change_function(); -void GC_change_foreground(); -void GC_change_background(); -void GC_change_linewidth(); -void GC_change_linestyle(); -void GC_change_capstyle(); -void GC_change_joinstyle(); -void GC_change_fillstyle(); -void GC_change_fillrule(); -void GC_change_arcmode(); -void GC_change_dashlist(); -void GC_change_planemask(); -void GC_change_font(); -void change_test(); -void change_percent(); - -extern void update_dashlist(); -extern void update_planemask(); -extern void update_slider(); -extern void select_button(); -extern void run_test(); -extern void print_if_recording(); - -extern XgcStuff TestStuff; -extern XgcStuff FunctionStuff; -extern XgcStuff LinestyleStuff; -extern XgcStuff CapstyleStuff; -extern XgcStuff JoinstyleStuff; -extern XgcStuff FillstyleStuff; -extern XgcStuff FillruleStuff; -extern XgcStuff ArcmodeStuff; - -extern XStuff X; -extern ChoiceDesc *GCdescs[]; -extern ChoiceDesc *testchoicedesc; -extern Widget test; -extern Widget GCform; -extern Widget foregroundtext; -extern Widget backgroundtext; -extern Widget linewidthtext; -extern Widget fonttext; -extern Widget dashlistchoice; -extern Widget planemaskchoice; -extern Widget testchoiceform; - -extern int fildes[2]; -extern FILE *outend; -extern FILE *yyin; /* interpret(string) ** ----------------- @@ -74,8 +25,7 @@ extern FILE *yyin; */ void -interpret(string) - const char *string; +interpret(const char *string) { char word1[20], word2[80]; int i; @@ -174,8 +124,7 @@ interpret(string) #ifdef notdef void -interpret(instring) - const char *instring; +interpret(const char *instring) { FILE *inend; @@ -199,9 +148,7 @@ interpret(instring) */ void -GC_change_function(function,feedback) - int function; - Boolean feedback; +GC_change_function(int function, Boolean feedback) { XSetFunction(X.dpy,X.gc,function); X.gcv.function = function; @@ -209,9 +156,7 @@ GC_change_function(function,feedback) } void -GC_change_foreground(foreground,feedback) - unsigned long foreground; - Boolean feedback; +GC_change_foreground(unsigned long foreground, Boolean feedback) { char text[40]; @@ -222,15 +167,13 @@ GC_change_foreground(foreground,feedback) XSetTile(X.dpy,X.gc,X.tile); XSetTile(X.dpy,X.miscgc,X.tile); if (feedback) { - sprintf(text,"%lu",foreground); + snprintf(text, sizeof text, "%lu",foreground); change_text(foregroundtext,text); } } void -GC_change_background(background,feedback) - unsigned long background; - Boolean feedback; +GC_change_background(unsigned long background, Boolean feedback) { char text[40]; @@ -247,30 +190,26 @@ GC_change_background(background,feedback) XClearWindow(X.dpy,XtWindow(test)); if (feedback) { - sprintf(text,"%lu",background); + snprintf(text, sizeof text, "%lu",background); change_text(backgroundtext,text); } } void -GC_change_linewidth(linewidth,feedback) - int linewidth; - Boolean feedback; +GC_change_linewidth(int linewidth, Boolean feedback) { char text[40]; X.gcv.line_width = linewidth; XChangeGC(X.dpy,X.gc,GCLineWidth,&X.gcv); if (feedback) { - sprintf(text,"%d",linewidth); + snprintf(text, sizeof text, "%d",linewidth); change_text(linewidthtext,text); } } void -GC_change_linestyle(linestyle,feedback) - int linestyle; - Boolean feedback; +GC_change_linestyle(int linestyle, Boolean feedback) { X.gcv.line_style = linestyle; XChangeGC(X.dpy,X.gc,GCLineStyle,&X.gcv); @@ -278,9 +217,7 @@ GC_change_linestyle(linestyle,feedback) } void -GC_change_capstyle(capstyle,feedback) - int capstyle; - Boolean feedback; +GC_change_capstyle(int capstyle, Boolean feedback) { X.gcv.cap_style = capstyle; XChangeGC(X.dpy,X.gc,GCCapStyle,&X.gcv); @@ -288,9 +225,7 @@ GC_change_capstyle(capstyle,feedback) } void -GC_change_joinstyle(joinstyle,feedback) - int joinstyle; - Boolean feedback; +GC_change_joinstyle(int joinstyle, Boolean feedback) { X.gcv.join_style = joinstyle; XChangeGC(X.dpy,X.gc,GCJoinStyle,&X.gcv); @@ -298,9 +233,7 @@ GC_change_joinstyle(joinstyle,feedback) } void -GC_change_fillstyle(fillstyle,feedback) - int fillstyle; - Boolean feedback; +GC_change_fillstyle(int fillstyle, Boolean feedback) { XSetFillStyle(X.dpy,X.gc,fillstyle); X.gcv.fill_style = fillstyle; @@ -308,9 +241,7 @@ GC_change_fillstyle(fillstyle,feedback) } void -GC_change_fillrule(fillrule,feedback) - int fillrule; - Boolean feedback; +GC_change_fillrule(int fillrule, Boolean feedback) { XSetFillRule(X.dpy,X.gc,fillrule); X.gcv.fill_rule = fillrule; @@ -318,9 +249,7 @@ GC_change_fillrule(fillrule,feedback) } void -GC_change_arcmode(arcmode,feedback) - int arcmode; - Boolean feedback; +GC_change_arcmode(int arcmode, Boolean feedback) { XSetArcMode(X.dpy,X.gc,arcmode); X.gcv.arc_mode = arcmode; @@ -336,9 +265,7 @@ GC_change_arcmode(arcmode,feedback) */ void -GC_change_dashlist(dashlist,feedback) - int dashlist; - Boolean feedback; +GC_change_dashlist(int dashlist, Boolean feedback) { char dasharray[DASHLENGTH]; /* what we're gonna pass to XSetDashes */ int dashnumber = 0; /* which element of dasharray we're currently @@ -381,9 +308,7 @@ GC_change_dashlist(dashlist,feedback) } void -GC_change_planemask(planemask,feedback) - unsigned long planemask; - Boolean feedback; +GC_change_planemask(unsigned long planemask, Boolean feedback) { XSetPlaneMask(X.dpy,X.gc,planemask); X.gcv.plane_mask = planemask; @@ -391,18 +316,14 @@ GC_change_planemask(planemask,feedback) } void -change_test(test,feedback) - int test; - Boolean feedback; +change_test(int test, Boolean feedback) { X.test = test; if (feedback) select_button(testchoicedesc,test); } void -GC_change_font(str,feedback) - const char *str; - Boolean feedback; +GC_change_font(char *str, Boolean feedback) { int num_fonts; /* number of fonts that match the string */ @@ -415,9 +336,7 @@ GC_change_font(str,feedback) } void -change_percent(percent,feedback) - int percent; - Boolean feedback; +change_percent(int percent, Boolean feedback) { /* Make sure that percent is valid */ @@ -28,7 +28,7 @@ other dealings in this Software without prior written authorization from the X Consortium. */ -/* $XFree86: xc/programs/xgc/main.c,v 1.5 2001/10/28 03:34:34 tsi Exp $ */ +/* $XFree86: xc/programs/xgc/main.c,v 1.7 2003/05/27 22:27:06 tsi Exp $ */ /* xgc ** @@ -51,28 +51,12 @@ from the X Consortium. #include "tile" #include "main.h" -static void fill_up_commandform(); -extern void run_test(); -static void quit(); -static void quitAction(); -static void clear_test_window(); -static void clear_result_window(); -extern void start_playback(); -extern void read_from_keyboard(); -extern void toggle_recordbutton(); -static void set_foreground_and_background(); -extern ChoiceDesc *create_choice(); -extern void choose_defaults(); -extern void line_up_labels(); -extern Widget create_text_choice(); -extern void create_planemask_choice(); -extern void create_dashlist_choice(); -extern void create_testfrac_choice(); -extern void GC_change_foreground(); -extern void GC_change_background(); -extern void GC_change_font(); -extern void close_file_if_recording(); -extern void set_text (Widget ww, char *string); +static void fill_up_commandform(Widget); +static void quit(void); +static void quitAction(Widget, XEvent *, String *, Cardinal *); +static void clear_test_window(void); +static void clear_result_window(void); +static void set_foreground_and_background(void); #ifdef notdef int fildes[2]; /* for pipe */ @@ -98,7 +82,6 @@ static Widget commandform; /* form with run, quit, clear, etc. */ Widget test; /* where the test is run */ Widget result; /* where the results are displayed */ static Widget runbutton; /* command for running */ -static Widget quitbutton; /* command for quitting */ static Widget clearbutton; /* command for clearing the test window */ Widget recordbutton; /* start/stop recording */ static Widget playbackbutton; /* playback from file */ @@ -126,9 +109,7 @@ static Widget percentchoice; /* form for choosing percentage of test */ */ int -main(argc,argv) - int argc; - char **argv; +main(int argc, char *argv[]) { static Arg shellargs[] = { {XtNinput, (XtArgVal) True} @@ -339,8 +320,7 @@ main(argc,argv) */ static void -fill_up_commandform(w) - Widget w; +fill_up_commandform(Widget w) { static XtCallbackRec runcallbacklist[] = { {(XtCallbackProc) run_test, NULL}, @@ -432,8 +412,8 @@ fill_up_commandform(w) quitargs[0].value = (XtArgVal) quitcallbacklist; quitargs[1].value = (XtArgVal) keyinputbutton; /* under */ - quitbutton = XtCreateManagedWidget("Quit",commandWidgetClass, - w,quitargs,XtNumber(quitargs)); + (void) XtCreateManagedWidget("Quit",commandWidgetClass, + w,quitargs,XtNumber(quitargs)); } /* quit() @@ -442,17 +422,13 @@ fill_up_commandform(w) */ static void -quit() +quit(void) { close_file_if_recording(); exit(0); } -static void quitAction(w, e, p, n) - Widget w; - XEvent *e; - String *p; - Cardinal *n; +static void quitAction(Widget w, XEvent *e, String *p, Cardinal *n) { if (e->type == ClientMessage && e->xclient.data.l[0] != wm_delete_window) XBell(XtDisplay(w), 0); @@ -466,7 +442,7 @@ static void quitAction(w, e, p, n) */ static void -clear_test_window() +clear_test_window(void) { XClearWindow(X.dpy,XtWindow(test)); } @@ -477,7 +453,7 @@ clear_test_window() */ static void -clear_result_window() +clear_result_window(void) { set_text(result, ""); } @@ -490,7 +466,7 @@ clear_result_window() */ static void -set_foreground_and_background() +set_foreground_and_background(void) { static XtResource resources[] = { {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), diff --git a/planemask.c b/planemask.c index e904aa3..1983432 100644 --- a/planemask.c +++ b/planemask.c @@ -7,7 +7,7 @@ ** functions to create more than one of these planemask choice things ** will fail in a big way. */ -/* $XFree86: xc/programs/xgc/planemask.c,v 1.3 2000/02/17 14:00:37 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/planemask.c,v 1.4 2003/05/07 21:02:07 herrb Exp $ */ #include <X11/Xos.h> #include <stdio.h> @@ -19,14 +19,7 @@ #include <X11/Xaw/Toggle.h> #include "xgc.h" -static void choose_plane( -#if NeedFunctionPrototypes - Widget, caddr_t, caddr_t -#endif -); -extern void interpret(); - -extern XStuff X; +static void choose_plane(Widget, caddr_t, caddr_t); static unsigned long planemask; static Widget *pm; @@ -39,8 +32,7 @@ static Widget *pm; */ void -create_planemask_choice(w) - Widget w; +create_planemask_choice(Widget w) { /* callback list for the toggle widgets */ static XtCallbackRec callbacklist[] = { @@ -81,7 +73,7 @@ create_planemask_choice(w) num_planes = PlanesOfScreen(X.scr); planemask = (1<<num_planes)-1; - sprintf(buf,"planemask %lu",planemask); + snprintf(buf, sizeof buf, "planemask %lu",planemask); interpret(buf); /* Allocate space for stuff that we don't know the size of yet */ @@ -115,7 +107,7 @@ create_planemask_choice(w) else pmargs[6].value = (XtArgVal) False; - sprintf(name,"planemask%d",i); + snprintf(name, sizeof name, "planemask%d",i); pminfo[i] = i; /* which bit we're on; this is needed in choose_plane (the callback) */ @@ -136,10 +128,7 @@ create_planemask_choice(w) /*ARGSUSED*/ static void -choose_plane(w,closure,call_data) - Widget w; - caddr_t closure; - caddr_t call_data; +choose_plane(Widget w, caddr_t closure, caddr_t call_data) { int num; /* what number button it is */ Boolean on; /* is it currently on or off? */ @@ -163,7 +152,7 @@ choose_plane(w,closure,call_data) else planemask &= ~(1<<num); - (void) sprintf(buf,"planemask %lu\n",planemask); + (void) snprintf(buf, sizeof buf, "planemask %lu\n",planemask); interpret(buf); } @@ -173,8 +162,7 @@ choose_plane(w,closure,call_data) */ void -update_planemask(mask) - long mask; +update_planemask(long mask) { int i; /* counter */ static Arg maskargs[] = { /* ArgList for setting toggle state */ @@ -3,7 +3,7 @@ ** ** record.c */ -/* $XFree86: xc/programs/xgc/record.c,v 1.3 2000/02/17 14:00:37 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/record.c,v 1.4 2003/05/07 21:02:07 herrb Exp $ */ #include <X11/Intrinsic.h> #include <X11/StringDefs.h> @@ -16,33 +16,16 @@ #include "xgc.h" -static void start_recording(); -static void stop_recording(); -static void print_out_gc_values(); -static void chose_playback_filename(); -static void cancel_playback(); -extern void get_filename(); -extern void yyparse(); - -extern XgcStuff TestStuff; -extern XgcStuff FunctionStuff; -extern XgcStuff LinestyleStuff; -extern XgcStuff CapstyleStuff; -extern XgcStuff JoinstyleStuff; -extern XgcStuff FillstyleStuff; -extern XgcStuff FillruleStuff; -extern XgcStuff ArcmodeStuff; - -extern XStuff X; -extern Boolean recording; -extern Widget filename_text_widget, recordbutton; - -static void cancel_record(); -static void done_choosing_filename(); +static void start_recording(void); +static void stop_recording(void); +static void print_out_gc_values(void); +static void chose_playback_filename(void); +static void cancel_playback(void); +static void done_choosing_filename(void) ; +static void cancel_record(void); FILE *recordfile; /* the file we're recording to */ FILE *playbackfile; /* the file we're playing back from */ -extern FILE *yyin; /* for yyparse */ /* toggle_recordbutton(w,closure,call_data) ** ---------------------------------------- @@ -54,10 +37,7 @@ extern FILE *yyin; /* for yyparse */ /*ARGSUSED*/ void -toggle_recordbutton(w,closure,call_data) - Widget w; - caddr_t closure; - caddr_t call_data; +toggle_recordbutton(Widget w, caddr_t closure, caddr_t call_data) { /* ArgList for changing the label */ static Arg recordargs[] = { @@ -72,7 +52,7 @@ toggle_recordbutton(w,closure,call_data) else { recording = FALSE; stop_recording(); - sprintf(tmp,"Record"); + snprintf(tmp, sizeof tmp, "Record"); recordargs[0].value = (XtArgVal) tmp; } @@ -86,7 +66,7 @@ toggle_recordbutton(w,closure,call_data) */ static void -start_recording() +start_recording(void) { get_filename(done_choosing_filename,cancel_record); } @@ -97,7 +77,7 @@ start_recording() */ static void -stop_recording() +stop_recording(void) { fclose(recordfile); } @@ -108,7 +88,7 @@ stop_recording() */ static void -cancel_record() +cancel_record(void) { } @@ -120,7 +100,7 @@ cancel_record() */ static void -done_choosing_filename() +done_choosing_filename(void) { static Arg recordargs[] = { {XtNlabel, (XtArgVal) NULL}, @@ -134,7 +114,7 @@ done_choosing_filename() if ((recordfile = fopen(filename,"w")) != NULL) { recording = TRUE; - sprintf(tmp,"End Record"); + snprintf(tmp, sizeof tmp, "End Record"); recordargs[0].value = (XtArgVal) tmp; XtSetValues(recordbutton,recordargs,XtNumber(recordargs)); @@ -148,8 +128,7 @@ done_choosing_filename() */ void -print_if_recording(str) - char *str; +print_if_recording(const char *str) { if (recording) fprintf(recordfile,"%s",str); @@ -161,7 +140,7 @@ print_if_recording(str) */ void -close_file_if_recording() +close_file_if_recording(void) { if (recording) fclose(recordfile); @@ -174,7 +153,7 @@ close_file_if_recording() */ static void -print_out_gc_values() +print_out_gc_values(void) { int i; for (i=0;i<NUM_TESTS;++i) { @@ -250,7 +229,7 @@ print_out_gc_values() */ void -start_playback() +start_playback(void) { get_filename(chose_playback_filename,cancel_playback); } @@ -261,7 +240,7 @@ start_playback() */ static void -cancel_playback() +cancel_playback(void) { } @@ -272,7 +251,7 @@ cancel_playback() */ static void -chose_playback_filename() +chose_playback_filename(void) { Arg args[1]; char *filename; @@ -292,7 +271,7 @@ chose_playback_filename() */ void -read_from_keyboard() +read_from_keyboard(void) { yyin = stdin; yyparse(); @@ -4,7 +4,7 @@ ** How to make a widget to choose the fraction of tests to be run. ** */ -/* $XFree86: xc/programs/xgc/testfrac.c,v 1.3 2000/02/17 14:00:37 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/testfrac.c,v 1.5 2003/09/13 21:33:11 dawes Exp $ */ #include <stdio.h> #include <X11/Intrinsic.h> @@ -14,10 +14,6 @@ #include <X11/Xaw/Scrollbar.h> #include "xgc.h" -extern void interpret(); - -extern XtAppContext appcontext; - #define SCROLLBAR_LENGTH 125 #define SLIDER_LENGTH 0.2 /* proportion of scrollbar taken up by the slider */ @@ -39,10 +35,7 @@ static int oldpercent = -1; /* so we only update when the slider has /*ARGSUSED*/ static void -slider_jump(w, data, position) - Widget w; - caddr_t data; - caddr_t position; +slider_jump(Widget w, caddr_t data, caddr_t position) { static Arg percentargs[] = { {XtNlabel, (XtArgVal) NULL} @@ -74,7 +67,7 @@ slider_jump(w, data, position) /* Update the label widget */ - sprintf(snewpercent,"%d",(int)(newpercent*100)); + snprintf(snewpercent, sizeof snewpercent, "%d",(int)(newpercent*100)); percentargs[0].value = (XtArgVal) snewpercent; XtSetValues(percent, percentargs, XtNumber(percentargs)); } @@ -87,26 +80,20 @@ slider_jump(w, data, position) /*ARGSUSED*/ static void -slider_scroll(w, data, position) - Widget w; - caddr_t data; - caddr_t position; -{} +slider_scroll(Widget w, caddr_t data, caddr_t position) +{ +} /*ARGSUSED*/ static void -update(w,event,params,num_params) - Widget w; - XEvent *event; - String *params; - int *num_params; +update(Widget w, XEvent *event, String *params, int *num_params) { char buf[80]; int newpercent; newpercent = (int)(fraction * 100.0); if (newpercent != oldpercent) { - sprintf(buf, "percent %d\n", (int)(fraction * 100.0)); + snprintf(buf, sizeof buf, "percent %d\n", (int)(fraction * 100.0)); interpret(buf); oldpercent = newpercent; } @@ -125,8 +112,7 @@ update(w,event,params,num_params) */ void -create_testfrac_choice(w) - Widget w; +create_testfrac_choice(Widget w) { static XtCallbackRec jumpcallbacks[] = { {(XtCallbackProc) slider_jump, NULL}, @@ -197,8 +183,7 @@ create_testfrac_choice(w) } void -update_slider(newpercent) - int newpercent; +update_slider(int newpercent) { fraction = (float) newpercent / 100.0; XawScrollbarSetThumb(slider, fraction / (1.0-SLIDER_LENGTH), SLIDER_LENGTH); @@ -1,6 +1,6 @@ /* ** $XConsortium: tests.c,v 1.20 91/06/08 18:57:07 rws Exp $ -** $XFree86: xc/programs/xgc/tests.c,v 1.10 2002/05/31 18:46:13 dawes Exp $ +** $XFree86: xc/programs/xgc/tests.c,v 1.12 2003/10/24 20:38:18 tsi Exp $ ** */ @@ -28,12 +28,6 @@ #define random lrand48 #endif -extern XStuff X; -extern Widget result; - -extern void GC_change_font(); -extern void print_if_recording(); -void show_result(); /* timer(flag) ** ----------- @@ -46,8 +40,7 @@ void show_result(); */ static long -timer(flag) - int flag; +timer(int flag) { #if !defined(SYSV) static struct timeval starttime; /* starting time for gettimeofday() */ @@ -96,7 +89,7 @@ timer(flag) return((long) NULL); } #else - static long starttime; + static time_t starttime; switch (flag) { case StartTimer: @@ -113,7 +106,7 @@ timer(flag) void -copyarea_test() +copyarea_test(void) { int num_copies = 200; int i; @@ -133,12 +126,12 @@ copyarea_test() XSync(X.dpy,0); totaltime = timer(EndTimer); - sprintf(buf,"%.2f seconds.",(double)totaltime/1000000.); + snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.); show_result(buf); } void -copyplane_test() +copyplane_test(void) { int num_copies = 200; int i; @@ -166,13 +159,12 @@ copyplane_test() totaltime = timer(EndTimer); XSetPlaneMask(X.dpy, X.gc, X.gcv.plane_mask); - sprintf(buf,"%.2f seconds.",(double)totaltime/1000000.); + snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.); show_result(buf); } void -circle_line_test(num_vertices,radius) - int num_vertices,radius; +circle_line_test(int num_vertices, int radius) { double theta, delta; int length, centerx, centery, i; @@ -201,7 +193,7 @@ circle_line_test(num_vertices,radius) XSync(X.dpy,0); totaltime = timer(EndTimer); - sprintf(buf,"%d lines of length %d in %.3f seconds.",num_vertices, + snprintf(buf,sizeof buf,"%d lines of length %d in %.3f seconds.",num_vertices, length,(double)totaltime/1000000.); show_result(buf); @@ -211,13 +203,13 @@ circle_line_test(num_vertices,radius) void -polyline_test() +polyline_test(void) { circle_line_test((int)(601*X.percent),190); } void -polysegment_test() +polysegment_test(void) { XSegment *segments; int num_segments = 600; @@ -245,7 +237,7 @@ polysegment_test() XSync(X.dpy,0); totaltime = end_timer(); - sprintf(buf,"%d segments in %.3f seconds.",num_segments, + snprintf(buf,sizeof buf,"%d segments in %.3f seconds.",num_segments, (double)totaltime/1000000.); show_result(buf); @@ -253,7 +245,7 @@ polysegment_test() } void -polypoint_test() +polypoint_test(void) { XPoint *points; int num_points = 100000; @@ -279,7 +271,7 @@ polypoint_test() XSync(X.dpy,0); totaltime = end_timer(); - sprintf(buf,"%d points in %.3f seconds.",num_points, + snprintf(buf,sizeof buf,"%d points in %.3f seconds.",num_points, (double)totaltime/1000000.); show_result(buf); @@ -287,8 +279,7 @@ polypoint_test() } void -genericrectangle_test(fill) - Boolean fill; +genericrectangle_test(Boolean fill) { XRectangle *rects; int num_rects = 200; @@ -316,9 +307,9 @@ genericrectangle_test(fill) totaltime = end_timer(); if (fill) - sprintf(buf,"%d pixels in %.2f seconds.",area,(double)totaltime/1000000.); + snprintf(buf,sizeof buf,"%d pixels in %.2f seconds.",area,(double)totaltime/1000000.); else - sprintf(buf,"Total line length %d in %.3f seconds.",perimeter, + snprintf(buf,sizeof buf,"Total line length %d in %.3f seconds.",perimeter, (double)totaltime/1000000.); show_result(buf); @@ -326,13 +317,13 @@ genericrectangle_test(fill) } void -polyrectangle_test() +polyrectangle_test(void) { genericrectangle_test(FALSE); } void -polyfillrectangle_test() +polyfillrectangle_test(void) { genericrectangle_test(TRUE); } @@ -340,7 +331,7 @@ polyfillrectangle_test() /*****************************/ void -fillpolygon_test() +fillpolygon_test(void) { int i; int points_per_side = 40; @@ -383,8 +374,7 @@ fillpolygon_test() /*****************************/ void -genericarc_test(fill) - Boolean fill; +genericarc_test(Boolean fill) { XArc *arcs; int num_arcs = 180; @@ -412,7 +402,7 @@ genericarc_test(fill) XSync(X.dpy,0); totaltime = end_timer(); - sprintf(buf,"An uncounted number of pixels in %.3f seconds.", + snprintf(buf,sizeof buf,"An uncounted number of pixels in %.3f seconds.", (double)totaltime/1000000.); show_result(buf); @@ -420,13 +410,13 @@ genericarc_test(fill) } void -polyarc_test() +polyarc_test(void) { genericarc_test(FALSE); } void -polyfillarc_test() +polyfillarc_test(void) { genericarc_test(TRUE); } @@ -434,7 +424,7 @@ polyfillarc_test() static const char string8[] = "pack my box with five dozen liquor jugs"; void -polytext8_test() +polytext8_test(void) { int num_strings = 200; int i; @@ -452,13 +442,13 @@ polytext8_test() XSync(X.dpy,0); totaltime = end_timer(); - sprintf(buf,"%d strings in %.2f seconds.",num_strings, + snprintf(buf,sizeof buf,"%d strings in %.2f seconds.",num_strings, (double) totaltime/1000000.); show_result(buf); } void -imagetext8_test() +imagetext8_test(void) { int num_strings = 200; int i; @@ -476,12 +466,12 @@ imagetext8_test() XSync(X.dpy,0); totaltime = end_timer(); - sprintf(buf,"%d strings in %.2f seconds.",num_strings, + snprintf(buf,sizeof buf,"%d strings in %.2f seconds.",num_strings, (double) totaltime/1000000.); show_result(buf); } -static const char unicode_font[] = +static char unicode_font[] = "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1"; static const XChar2b string16[] = { @@ -508,7 +498,7 @@ static const XChar2b string16[] = { }; void -polytext16_test() +polytext16_test(void) { int num_strings = 50; int i; @@ -530,13 +520,13 @@ polytext16_test() GC_change_font(X.fontname,FALSE); - sprintf(buf,"%d strings in %.2f seconds.",num_strings, + snprintf(buf,sizeof buf,"%d strings in %.2f seconds.",num_strings, (double) totaltime/1000000.); show_result(buf); } void -imagetext16_test() +imagetext16_test(void) { int num_strings = 50; int i; @@ -558,13 +548,13 @@ imagetext16_test() GC_change_font(X.fontname,FALSE); - sprintf(buf,"%d strings in %.2f seconds.",num_strings, + snprintf(buf,sizeof buf,"%d strings in %.2f seconds.",num_strings, (double) totaltime/1000000.); show_result(buf); } void -putimage_test() +putimage_test(void) { int num_copies = 200; int i; @@ -585,7 +575,7 @@ putimage_test() XSync(X.dpy,0); totaltime = timer(EndTimer); - sprintf(buf,"%.2f seconds.",(double)totaltime/1000000.); + snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.); show_result(buf); } @@ -594,7 +584,7 @@ putimage_test() /*****************************/ void -run_test() +run_test(void) { XClearWindow(X.dpy,X.win); @@ -628,9 +618,7 @@ run_test() */ void -set_text(w,string) - Widget w; - char *string; +set_text(Widget w, char *string) { static Arg args[2]; @@ -640,8 +628,7 @@ set_text(w,string) } void -show_result(string) - char *string; +show_result(char *string) { char buf[80]; @@ -6,7 +6,7 @@ ** How to make a text widget that returns a string when the cursor ** leaves its window. */ -/* $XFree86: xc/programs/xgc/text.c,v 1.3 2000/02/17 14:00:37 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/text.c,v 1.4 2003/05/07 21:02:07 herrb Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -17,11 +17,7 @@ #include <X11/Xaw/AsciiText.h> #include "xgc.h" -static void WriteText(); -extern void interpret(); - -extern XStuff X; -extern XtAppContext appcontext; +static void WriteText(Widget, XEvent *, String *, Cardinal *); /* the strings which are displayed on the screen, edited, and sent to interpret() */ @@ -51,10 +47,7 @@ static const char *names[NUMTEXTWIDGETS] = {"linewidth ","font ","foreground ", */ Widget -create_text_choice(w,type,length,width) - Widget w; - int type; - int length, width; +create_text_choice(Widget w, int type, int length, int width) { char translationtable[600]; /* for adding the new action (calling WriteText() when the pointer leaves) */ @@ -88,7 +81,7 @@ create_text_choice(w,type,length,width) ** update the GC accordingly. The integer passed to WriteText is ** so it knows what type of widget was just updated. */ - sprintf(translationtable, + snprintf(translationtable,sizeof translationtable, "<Leave>: WriteText(%d)\n\ Ctrl<Key>J: Nothing()\n\ Ctrl<Key>M: Nothing()\n\ @@ -110,12 +103,16 @@ create_text_choice(w,type,length,width) /* text uses type to find out what its string is */ switch (type) { case TForeground: - sprintf(textstrings[type],"%d",(int) X.gcv.foreground); - sprintf(oldtextstrings[type],"%d",(int) X.gcv.foreground); + snprintf(textstrings[type],sizeof textstrings[type], + "%d",(int) X.gcv.foreground); + snprintf(oldtextstrings[type],sizeof oldtextstrings[type], + "%d",(int) X.gcv.foreground); break; case TBackground: - sprintf(textstrings[type],"%d",(int) X.gcv.background); - sprintf(oldtextstrings[type],"%d",(int) X.gcv.background); + snprintf(textstrings[type],sizeof textstrings[type], + "%d",(int) X.gcv.background); + snprintf(oldtextstrings[type],sizeof oldtextstrings[type], + "%d",(int) X.gcv.background); break; default: strcpy(textstrings[type],defaultstrings[type]); @@ -146,11 +143,7 @@ create_text_choice(w,type,length,width) /*ARGSUSED*/ static void -WriteText(w,event,params,num_params) - Widget w; - XEvent *event; - String *params; /* the type is in here */ - Cardinal *num_params; +WriteText(Widget w, XEvent *event, String *params, Cardinal *num_params) { char mbuf[80]; int type; /* which string # to send */ @@ -158,9 +151,9 @@ WriteText(w,event,params,num_params) type = atoi(params[0]); if (strcmp(textstrings[type],oldtextstrings[type])) { strcpy(oldtextstrings[type],textstrings[type]); - sprintf(mbuf,names[type]); /* the right first half */ - strcat(mbuf,textstrings[type]); /* the right second half */ - strcat(mbuf,"\n"); /* the right newline */ + snprintf(mbuf,sizeof mbuf,"%s%s\n", + names[type], /* the right first half */ + textstrings[type]); /* the right second half */ interpret(mbuf); /* send it off */ } } @@ -171,9 +164,7 @@ WriteText(w,event,params,num_params) */ void -change_text(w,newtext) - Widget w; - String newtext; +change_text(Widget w, String newtext) { XawTextBlock text; /* the new text */ XawTextPosition first, last; /* boundaries of the old text */ @@ -3,7 +3,7 @@ ** ** xgc.h */ -/* $XFree86: xc/programs/xgc/xgc.h,v 1.3 2000/02/17 14:00:38 dawes Exp $ */ +/* $XFree86: xc/programs/xgc/xgc.h,v 1.6 2003/09/13 21:33:11 dawes Exp $ */ #include "constants.h" @@ -61,4 +61,108 @@ typedef struct { WidgetList widgets; } ChoiceDesc; +#ifndef HAS_SNPRINTF +#include <X11/Xmu/SysUtil.h> +#define snprintf XmuSnprintf +#endif + +/************/ + +extern XStuff X; +extern Widget topform; +extern XtAppContext appcontext; + +extern XgcStuff TestStuff; +extern XgcStuff FunctionStuff; +extern XgcStuff LinestyleStuff; +extern XgcStuff CapstyleStuff; +extern XgcStuff JoinstyleStuff; +extern XgcStuff FillstyleStuff; +extern XgcStuff FillruleStuff; +extern XgcStuff ArcmodeStuff; + +extern ChoiceDesc *GCdescs[]; +extern ChoiceDesc *testchoicedesc; +extern Widget test; +extern Widget GCform; +extern Widget foregroundtext; +extern Widget backgroundtext; +extern Widget linewidthtext; +extern Widget fonttext; +extern Widget dashlistchoice; +extern Widget planemaskchoice; +extern Widget testchoiceform; + +extern Widget result; + +extern Boolean recording; +extern Widget filename_text_widget, recordbutton; + +extern int fildes[2]; +extern FILE *outend; +extern FILE *yyin; + /************/ + +extern void change_percent(int, Boolean); +extern void change_test(int, Boolean); +extern void change_text(Widget, String); +extern void choose_defaults(ChoiceDesc *[], int); +extern void circle_line_test(int, int); +extern void close_file_if_recording(void); +extern void copyarea_test(void); +extern void copyplane_test(void); +extern ChoiceDesc * create_choice(Widget, XgcStuff *); +extern void create_dashlist_choice(Widget); +extern void create_planemask_choice(Widget); +extern void create_testfrac_choice(Widget); +extern Widget create_text_choice(Widget, int, int, int); +extern void fillpolygon_test(void); +extern void GC_change_arcmode(int, Boolean); +extern void GC_change_background(unsigned long, Boolean); +extern void GC_change_capstyle(int, Boolean); +extern void GC_change_dashlist(int, Boolean); +extern void GC_change_fillrule(int, Boolean); +extern void GC_change_fillstyle(int, Boolean); +extern void GC_change_font(char *, Boolean); +extern void GC_change_foreground(unsigned long, Boolean); +extern void GC_change_function(int, Boolean); +extern void GC_change_joinstyle(int, Boolean); +extern void GC_change_linestyle(int, Boolean); +extern void GC_change_linewidth(int, Boolean); +extern void GC_change_planemask(unsigned long, Boolean); +extern void genericarc_test(Boolean); +extern void genericrectangle_test(Boolean); +extern void get_filename(void (*)(void), void (*)(void)); +extern void imagetext16_test(void); +extern void imagetext8_test(void); +extern void interpret(const char *); +extern void line_up_labels(ChoiceDesc *[], int); +extern void polyarc_test(void); +extern void polyfillarc_test(void); +extern void polyfillrectangle_test(void); +extern void polyline_test(void); +extern void polypoint_test(void); +extern void polyrectangle_test(void); +extern void polysegment_test(void); +extern void polytext16_test(void); +extern void polytext8_test(void); +extern void print_if_recording(const char *); +extern void putimage_test(void); +extern void read_from_keyboard(void); +extern void run_test(void); +extern void select_button(ChoiceDesc *, int); +extern void set_text(Widget, char *); +extern void show_result(char *); +extern void start_playback(void); +extern void toggle_recordbutton(Widget, caddr_t, caddr_t); +extern void update_dashlist(int); +extern void update_planemask(long); +extern void update_slider(int); +extern void yyerror(const char *); +extern int yylex(void); +extern int yyparse(void); +extern void yyrestart(FILE *); +extern int yywrap(void); + + |