=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/Attic/term.c,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.3 diff -u -p -r1.1.1.2 -r1.1.1.3 --- OpenXM_contrib/gnuplot/Attic/term.c 2000/01/22 14:16:02 1.1.1.2 +++ OpenXM_contrib/gnuplot/Attic/term.c 2003/09/15 07:09:26 1.1.1.3 @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: term.c,v 1.1.1.2 2000/01/22 14:16:02 maekawa Exp $"; +static char *RCSid = "$Id: term.c,v 1.1.1.3 2003/09/15 07:09:26 ohara Exp $"; #endif /* GNUPLOT - term.c */ @@ -112,6 +112,7 @@ extern float xsize, ysize; /* internal pointsize for do_point */ static double term_pointsize; +int termcomp __PROTO((SORTFUNC_ARGS a, SORTFUNC_ARGS b)); static void term_suspend __PROTO((void)); static void term_close_output __PROTO((void)); static void null_linewidth __PROTO((double)); @@ -829,21 +830,40 @@ term_count() void list_terms() { register int i; - char line_buffer[BUFSIZ]; + char *line_buffer = gp_alloc(BUFSIZ, "list_terms"); + int sort_idxs[TERMCOUNT]; + /* sort terminal types alphabetically */ + for( i = 0; i < TERMCOUNT; i++ ) + sort_idxs[i] = i; + qsort( sort_idxs, TERMCOUNT, sizeof(int), termcomp ); + /* now sort_idxs[] contains the sorted indices */ + StartOutput(); - sprintf(line_buffer,"\nAvailable terminal types:\n"); + strcpy(line_buffer, "\nAvailable terminal types:\n"); OutLine(line_buffer); for (i = 0; i < TERMCOUNT; i++) { - sprintf(line_buffer," %15s %s\n", - term_tbl[i].name, term_tbl[i].description); + sprintf(line_buffer, " %15s %s\n", + term_tbl[sort_idxs[i]].name, + term_tbl[sort_idxs[i]].description); OutLine(line_buffer); } EndOutput(); + free(line_buffer); } +int +termcomp(arga, argb) + SORTFUNC_ARGS arga; + SORTFUNC_ARGS argb; +{ + const int *a = arga; + const int *b = argb; + + return( strcasecmp( term_tbl[*a].name, term_tbl[*b].name ) ); +} /* set_term: get terminal number from name on command line * will change 'term' variable if successful