Changeset 420 for trunk


Ignore:
Timestamp:
02/27/08 07:13:31 (12 years ago)
Author:
Nicholas Riley
Message:

Jgraph: my changes - ANSIfication, few minor bug fixes; works on OS X 10.5 now

Location:
trunk/Jgraph
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jgraph/draw.c

    r419 r420  
    2222      error_header();
    2323      fprintf(stderr,
    24               "Value of %f is at negative infinity with logrhythmic %c axis\n",
     24              "Value of %f is at negative infinity with logarithmic %c axis\n",
    2525              val, (axis->is_x) ? 'x' : 'y');
    26        exit(1);
     26      exit(1);
    2727    }
    2828    return (log(val) / axis->logfactor - axis->logmin) * axis->factor;
     
    5151#define MAXIMUM(a,b) ((a > b) ? a : b)
    5252
    53 draw_axis(a, other)
    54 Axis a, other;
     53void draw_label(Label l)
     54{
     55  if (l->label == CNULL) return;
     56  comment(l->label);
     57  print_label(l);
     58}
     59
     60void draw_axis(Axis a, Axis other)
    5561{
    5662  char orientation;
     
    117123
    118124
    119 draw_label(l)
    120 Label l;
    121 {
    122   if (l->label == CNULL) return;
    123   comment(l->label);
    124   print_label(l);
    125 }
    126 
    127 set_clip(g)
    128 Graph g;
     125void set_clip(Graph g)
    129126{
    130127  comment("Setting Clip");
     
    136133}
    137134
    138 draw_curves(g)
    139 Graph g;
     135void draw_curve(Curve c, Graph g);
     136
     137void draw_curves(Graph g)
    140138{
    141139  Curve c;
     
    151149}
    152150
    153 draw_curve(c, g)
    154 Curve c;
    155 Graph g;
     151void draw_mark(float x, float y, Curve c, Graph g);
     152void draw_arrow(float x1, float y1, float x2, float y2, Curve c);
     153
     154void draw_curve(Curve c, Graph g)
    156155{
    157156  Point p, px, py;
     
    270269}
    271270
    272 draw_mark(x, y, c, g)
    273 float x, y;
    274 Curve c;
    275 Graph g;
     271void draw_mark(float x, float y, Curve c, Graph g)
    276272{
    277273  Point p;
     
    317313              }
    318314              for (i = 0; i < 4; i++) {
    319                 if (fscanf(f, "%d", &(bb[i])) == NULL) {
     315                if (fscanf(f, "%d", &(bb[i])) == 0) {
    320316                  fprintf(stderr, "Error: Eps file '%s': eof in %s\n",
    321317                          c->eps, "bounding box");
     
    502498}
    503499
    504 draw_arrow(x1, y1, x2, y2, c)
    505 float x1, y1, x2, y2;
    506 Curve c;
     500void draw_arrow(float x1, float y1, float x2, float y2, Curve c)
    507501{
    508502  float dx, dy;
     
    542536}
    543537
    544 draw_legend(g)
    545 Graph g;
     538void draw_legend(Graph g)
    546539{
    547540  Curve c;
     
    606599}
    607600
    608 draw_strings(g)
    609 Graph g;
     601void draw_strings(Graph g)
    610602{
    611603  String s;
     
    616608}
    617609
    618 draw_graph(g)
    619 Graph g;
     610void draw_graph(Graph g)
    620611{
    621612  comment("Drawing New Graph");
     
    637628}
    638629
    639 draw_graphs(gs, pp, landscape)
    640 Graphs gs;
    641 int pp;
    642 int landscape;
     630void draw_header(Graphs gs, int pp, int landscape);
     631void draw_footer(Graphs gs, int pp);
     632
     633void draw_graphs(Graphs gs, int pp, int landscape)
    643634{
    644635  Graphs gs_p;
     
    661652}
    662653
    663 draw_header(gs, pp, landscape)
    664 Graphs gs;
    665 int pp;
    666 int landscape;
     654void draw_header(Graphs gs, int pp, int landscape)
    667655{
    668656  FILE *f;
     
    774762    }
    775763  } else if (landscape) {
    776     printf("%f 0 translate\n", -gs->bb[2] - gs->bb[0]);
     764    printf("%d 0 translate\n", -gs->bb[2] - gs->bb[0]);
    777765  }
    778766  printf("1 setlinecap 1 setlinejoin\n");
     
    835823}
    836824
    837 draw_footer(gs, pp)
    838 Graphs gs;
    839 int pp;
     825void draw_footer(Graphs gs, int pp)
    840826{
    841827  FILE *f;
  • trunk/Jgraph/edit.c

    r418 r420  
    88
    99#include <stdio.h>
     10#include <string.h>
    1011
    1112#include "jgraph.h"
     
    1415#define MIN(a,b) ((a < b) ? a : b)
    1516
    16 edit_label(l)
    17 Label l;
     17void edit_label(Label l)
    1818{
    1919  char *txt, inp_str[80];
     
    7373}
    7474
    75 copy_curve(c1, c2) /* Copies curve c2 to c1 */
    76 Curve c1, c2;
     75void copy_curve(Curve c1, Curve c2) /* Copies curve c2 to c1 */
    7776{
    7877  Flist f, newf;
     
    139138}
    140139
    141 copy_label(l1, l2) /* Copies label l2 to l1 */
    142 Label l1, l2;
     140void copy_label(Label l1, Label l2) /* Copies label l2 to l1 */
    143141{
    144142  l1->label = l2->label;
     
    157155}
    158156
    159 copy_axis(a1, a2) /* Copies axis a2 to a1 */
    160 Axis a1, a2;
     157void copy_axis(Axis a1, Axis a2) /* Copies axis a2 to a1 */
    161158{
    162159  copy_label(a1->label, a2->label);
     
    202199}
    203200
    204 Curve do_copy_curve(g, gs, all_gs)
    205 Graph g;
    206 Graphs gs;
    207 Graphs all_gs;
     201Curve do_copy_curve(Graph g, Graphs gs, Graphs all_gs)
    208202{
    209203  Curve lastc, newc;
     
    255249}
    256250
    257 Label do_copy_string(g, gs, all_gs)
    258 Graph g;
    259 Graphs gs;
    260 Graphs all_gs;
     251Label do_copy_string(Graph g, Graphs gs, Graphs all_gs)
    261252{
    262253  String lastl, newl;
     
    308299}
    309300
    310 Graph last_graph(g, gs, all_gs)
    311 Graph g;
    312 Graphs gs;
    313 Graphs all_gs;
     301Graph last_graph(Graph g, Graphs gs, Graphs all_gs)
    314302{
    315303  Graph lastg;
     
    330318}
    331319
    332 copy_legend(l1, l2)
    333 Legend l1, l2;
     320void copy_legend(Legend l1, Legend l2)
    334321{
    335322  l1->linelength = l2->linelength;
     
    340327}
    341328
    342 inherit_axes(g, lastg)
    343 Graph g;
    344 Graph lastg;
     329void inherit_axes(Graph g, Graph lastg)
    345330{
    346331  char *s;
     
    357342}
    358343
    359 getpattern(inp_str, key, p, a)
    360 char *inp_str, *key, *p;
    361 float *a;
     344void getpattern(char *inp_str, char *key, char *p, float *a)
    362345{
    363346  int i;
     
    386369}
    387370
    388 edit_curve(c, g)
    389 Curve c;
    390 Graph g;
     371void edit_curve(Curve c, Graph g)
    391372{
    392373  char inp_str[256], *txt;
     
    681662}
    682663
    683 edit_hash_label(a)
    684 Axis a;
     664void edit_hash_label(Axis a)
    685665{
    686666  float at, f;
     
    732712}
    733713
    734 edit_axis(a)
    735 Axis a;
     714void edit_axis(Axis a)
    736715{
    737716  char inp_str[256];
     
    908887}
    909888
    910 edit_legend(l)
    911 Legend l;
     889void edit_legend(Legend l)
    912890{
    913891  char inp_str[256];
     
    975953}
    976954
    977 edit_graph(g, gs, all_gs)
    978 Graph g;
    979 Graphs gs;
    980 Graphs all_gs;
     955void edit_graph(Graph g, Graphs gs, Graphs all_gs)
    981956{
    982957  char inp_str[80];
     
    10501025}
    10511026
    1052 edit_graphs(gs)
    1053 Graphs gs;
     1027void edit_graphs(Graphs gs)
    10541028{
    10551029  Graphs the_g;
  • trunk/Jgraph/jgraph.c

    r418 r420  
    77
    88#include <stdio.h>
     9#include <string.h>
    910
    1011#ifdef VMS
     
    297298}
    298299
    299 new_graphs(gs)
    300 Graphs gs;
     300void new_graphs(Graphs gs)
    301301{
    302302  Graphs newg;
     
    316316}
    317317
    318 main(argc, argv)
    319 int argc;
    320 char **argv;
     318int main(int argc, char **argv)
    321319{
    322320  Graphs gs;
  • trunk/Jgraph/jgraph.h

    r418 r420  
    241241extern char PTYPES[];
    242242extern int NPATTERNS;
     243
     244void new_graphs(Graphs gs);
     245
     246/* Stuff defined in printline.c */
     247
     248void print_label(Label l);
     249void set_comment(int c);
     250void comment(char *s);
     251void gsave(void);
     252void grestore(void);
     253void setlinewidth(float size);
     254void setlinestyle(char style, Flist glist);
     255void print_ebar(float x1, float y1, float x2, float ms, char orientation);
     256void start_line(float x1, float y1, Curve c);
     257void bezier_control(float x1, float y1);
     258void bezier_end(float x1, float y1);
     259void end_line(void);
     260void setfill(float x, float y, char t, float f[], char p, float a);
     261void cont_line(float x1, float y1);
     262void setgray(char t, float f[]);
     263void printline(float x1, float y1, float x2, float y2, char orientation);
     264void start_poly(float x1, float y1);
     265void cont_poly(float x1, float y1);
     266void end_poly(float x, float y, char ftype, float fill[],
     267              char pattern, float parg);
     268void printellipse(float x, float y, float radius1, float radius2,
     269                  char ftype, float fill[], char pattern, float parg);
     270void setfont(char *f, float s);
     271
     272/* Stuff defined in edit.c */
     273
     274void copy_label(Label l1, Label l2);
     275void edit_graphs(Graphs gs);
     276
     277/* Stuff defined in token.c */
     278
     279void set_input_file(char *s);
     280int getint(int *i);
     281int getstring(char *s);
     282int getfloat(float *f);
     283void rejecttoken(void);
     284
     285/* Stuff defined in process.c */
     286
     287void process_graphs(Graphs gs);
     288
     289/* Stuff defined in show.c */
     290
     291void show_graphs(Graphs gs);
     292
     293/* Stuff defined in draw.c */
     294
     295void draw_graphs(Graphs gs, int pp, int landscape);
  • trunk/Jgraph/list.c

    r418 r420  
    77
    88#include <stdio.h>    /* Basic includes and definitions */
     9#include <stdlib.h>
    910#include "list.h"
    1011
     
    3334} *Int_list;
    3435
    35 insert(item, list)      /* Inserts to the end of a list */
    36 List item;
    37 List list;
     36void insert(void *item, void *list)     /* Inserts to the end of a list */
    3837{
    3938  List last_node;
    4039
    41   last_node = list->blink;
     40  last_node = ((List)list)->blink;
    4241
    43   list->blink = item;
     42  ((List)list)->blink = item;
    4443  last_node->flink = item;
    45   item->blink = last_node;
    46   item->flink = list;
     44  ((List)item)->blink = last_node;
     45  ((List)item)->flink = list;
    4746}
    4847
    49 delete_item(item)               /* Deletes an arbitrary iterm */
    50 List item;
     48void delete_item(void *item)            /* Deletes an arbitrary iterm */
    5149{
    52   item->flink->blink = item->blink;
    53   item->blink->flink = item->flink;
     50  ((List)item)->flink->blink = ((List)item)->blink;
     51  ((List)item)->blink->flink = ((List)item)->flink;
    5452}
    5553
     
    6866}
    6967 
    70 List get_node(list)   /* Allocates a node to be inserted into the list */
    71 List list;
     68List get_node(void *list)   /* Allocates a node to be inserted into the list */
    7269{
    7370  Int_list l;
     
    8481}
    8582
    86 free_node(node, list)    /* Deallocates a node from the list */
    87 List node;
    88 List list;
     83void free_node(void *node, void *list)    /* Deallocates a node from the list */
    8984{
    9085  Int_list l;
    9186 
    9287  l = (Int_list) list;
    93   node->flink = l->free_list;
     88  ((List)node)->flink = l->free_list;
    9489  l->free_list = node;
    9590}
  • trunk/Jgraph/list.h

    r418 r420  
    2424#define prev(n) (n->blink)
    2525
    26 /* These are the routines for manipluating lists */
     26/* These are the routines for manipulating lists */
    2727
    28 /* void insert(node list);    Inserts a node to the end of a list */
    29 /* void delete_item(node);    Deletes an arbitrary node */
    30 /* List make_list(node_size); Creates a new list */
    31 /* List get_node(list);        Allocates a node to be inserted into the list */
    32 /* void free_node(node, list); Deallocates a node from the list */
     28void insert(void *, void *);/* Inserts a node to the end of a list */
     29void delete_item(void *);   /* Deletes an arbitrary node */
     30List make_list(int size);   /* Creates a new list */
     31List get_node(void *);      /* Allocates a node to be inserted into the list */
     32void free_node(void *, void *); /* Deallocates a node from the list */
    3333
     34void error_header();
  • trunk/Jgraph/makefile

    r419 r420  
    77# jgraph.1 to be the directory containing the example jgraphs.
    88
    9 CC = cc
     9CC = gcc -DLCC -Wall
    1010
    1111OBJS = draw.o \
     
    9494token.o: token.c list.h
    9595clean:
    96         rm -f *.o a.out *.jps jgraph
     96        rm -f *.o a.out *.jps *.eps jgraph sin
  • trunk/Jgraph/printline.c

    r419 r420  
    99#include <stdio.h>
    1010#include <assert.h> //by pzn@debian.org
     11#include <string.h>
    1112
    1213#define LINEWIDTHFACTOR 0.700
     
    2526static int Jgraph_comment;
    2627
    27 gsave()
     28void gsave(void)
    2829{
    2930  if (Jgraph_gsave_level == -100) {
     
    3536}
    3637
    37 grestore()
     38void grestore(void)
    3839{
    3940  Fontlist l;
     
    5051}
    5152
    52 setfont(f, s)
    53 char *f;
    54 float s;
     53void setfont(char *f, float s)
    5554{
    5655  Fontlist l;
     
    7776}
    7877 
    79 setfill( x, y, t, f, p, a)
    80 char t, p ;
    81 float x, y;
    82 float f[], a ;
     78void setfill(float x, float y, char t, float f[], char p, float a)
    8379{
    8480/*   fprintf(stderr, "Hello?  %c %f %c %f\n", t, f[0], p, a); */
     
    10298}
    10399
    104 setgray( t, f)
    105 char t ;
    106 float f[] ;
     100void setgray(char t, float f[])
    107101{
    108102    if ( t == 'g' )  {
     
    113107}
    114108
    115 printline(x1, y1,x2, y2, orientation)
    116 float x1, y1, x2, y2;
    117 char orientation;
     109void printline(float x1, float y1, float x2, float y2, char orientation)
    118110{
    119111  if (orientation == 'x')
     
    124116}
    125117
    126 print_ebar(x1, y1, x2, ms, orientation)
    127 float x1, y1, x2, ms;
    128 char orientation;
     118void print_ebar(float x1, float y1, float x2, float ms, char orientation)
    129119{
    130120  printline(x1, y1, x2, y1, orientation);
     
    132122}
    133123
    134 start_line(x1, y1, c)
    135 float x1, y1;
    136 Curve c;
     124void start_line(float x1, float y1, Curve c)
    137125{
    138126  setlinewidth(c->linethick);
     
    141129}
    142130
    143 cont_line(x1, y1)
    144 float x1, y1;
     131void cont_line(float x1, float y1)
    145132{
    146133  printf("  %f %f lineto\n", x1, y1);
    147134}
    148135
    149 end_line()
     136void end_line(void)
    150137{
    151138  printf("stroke\n");
     
    156143}
    157144
    158 bezier_control(x1, y1)
    159 float x1, y1;
     145void bezier_control(float x1, float y1)
    160146{
    161147  printf("  %f %f ", x1, y1);
    162148}
    163149
    164 bezier_end(x1, y1)
    165 float x1, y1;
     150void bezier_end(float x1, float y1)
    166151{
    167152  printf("  %f %f curveto\n", x1, y1);
     
    169154
    170155
    171 start_poly(x1, y1)
    172 float x1, y1;
     156void start_poly(float x1, float y1)
    173157{
    174158  printf(" newpath %f %f moveto", x1, y1);
    175159}
    176160
    177 cont_poly(x1, y1)
    178 float x1, y1;
     161void cont_poly(float x1, float y1)
    179162{
    180163  printf("  %f %f lineto\n", x1, y1);
    181164}
    182165
    183 end_poly(x, y, ftype, fill, pattern, parg)
    184 float x, y;
    185 char  ftype, pattern ;
    186 float fill[], parg;
     166void end_poly(float x, float y, char ftype, float fill[],
     167              char pattern, float parg)
    187168{
    188169  printf("closepath ");
     
    194175/* Ellipse at 0, 0 -- assumes that you've already translated to x, y */
    195176
    196 printellipse(x, y, radius1, radius2, ftype, fill, pattern, parg)
    197 char ftype, pattern;
    198 float x, y, radius1, radius2, fill[], parg;
     177void printellipse(float x, float y, float radius1, float radius2,
     178                  char ftype, float fill[], char pattern, float parg)
    199179{
    200180  printf("newpath %f %f JDE\n", radius1, radius2);
     
    204184}
    205185
    206 set_comment(c)
    207 int c;
     186void set_comment(int c)
    208187{
    209188  Jgraph_comment = c;
    210189}
    211190
    212 comment(s)
    213 char *s;
     191void comment(char *s)
    214192{
    215193  if (Jgraph_comment) printf("%% %s\n", s);
    216194}
    217195
    218 printline_c(x1, y1, x2, y2, g)
    219 float x1, y1, x2, y2;
    220 Graph g;
     196void printline_c(float x1, float y1, float x2, float y2, Graph g)
    221197{
    222198  printline(ctop(x1, g->x_axis), ctop(y1, g->y_axis),
     
    224200}
    225201
    226 print_label(l)
    227 Label l;
     202void print_label(Label l)
    228203{
    229204  int f, i, nlines;
    230205  float fnl;
    231206  char *s;
    232   unsigned char *s_7bit; // added by pzn@debian.org
     207  char *s_7bit; // added by pzn@debian.org
    233208
    234209  if (l->label == CNULL) return;
     
    317292}
    318293
    319 setlinewidth(size)
    320 float size;
     294void setlinewidth(float size)
    321295{
    322296  printf("%f setlinewidth ", size * LINEWIDTHFACTOR);
    323297}
    324298
    325 setlinestyle(style, glist)
    326 char style;
    327 Flist glist;
     299void setlinestyle(char style, Flist glist)
    328300{
    329301  Flist fl;
  • trunk/Jgraph/prio_list.c

    r418 r420  
    1010#include <stdio.h>
    1111
    12 typedef int Boolean;
    13 
    14 /* A prioirity list is any list with the first three fields being flink,
    15  * blink and prio.  Use the routines of list.c to do everything except
    16  * insertion */
    17  
    18 typedef struct prio_list {
    19   struct prio_list *flink;
    20   struct prio_list *blink;
    21   int prio;
    22 } *Prio_list;
    2312
    2413/* Prio_insert inserts nodes into their proper places in priority lists.  It first
     
    2615 * Thus, it is worst case linear, but for most cases constant time (right). */
    2716
    28 prio_insert(node, list, desc)
    29 Prio_list node;
    30 Prio_list list;
    31 Boolean desc;
     17void prio_insert(void *n, void *l, Boolean desc)
    3218{
    33   Prio_list p;
     19  Prio_list p, node = (Prio_list)n, list = (Prio_list)l;
    3420
    3521  /* Check nil and head of list */
  • trunk/Jgraph/prio_list.h

    r418 r420  
    66 */
    77
    8 /* Priority lists are just like normal lists of list.h and list.c, except
    9  * that their third field is a (int) prioriy.  The routines of list.c should all
    10  * be used except for insert, because it will always put an item at the
    11  * end of a list.  Instead, use prio_insert, which will put the item
    12  * into its proper place in the list.  The last argument of prio_insert should
    13  * be TRUE if the list is to be kept in descending order; it should be FALSE
    14  * for ascending order.
     8/* Priority lists are just like normal lists of list.h and list.c,
     9 * except that their third field is a (int) priority.  The routines of
     10 * list.c should all be used except for insert, because it will always
     11 * put an item at the end of a list.  Instead, use prio_insert, which
     12 * will put the item into its proper place in the list.  The last
     13 * argument of prio_insert should be TRUE if the list is to be kept in
     14 * descending order; it should be FALSE for ascending order.
     15 */
    1516
    16  * Priority list should be:
    17 
    18 struct prio_list {
     17/* A priority list is any list with the first three fields being flink,
     18 * blink and prio.  Use the routines of list.c to do everything except
     19 * insertion */
     20 
     21typedef struct prio_list {
    1922  struct prio_list *flink;
    2023  struct prio_list *blink;
    2124  int prio;
    22   ...
    23   }
     25  /* ... */
     26} *Prio_list;
    2427
    25 */
     28typedef int Boolean;
    2629
    27 /* void prio_insert(node, list, descending); */
     30void prio_insert(void *node, void *list, Boolean descending);
    2831
  • trunk/Jgraph/process.c

    r418 r420  
    88#include <stdio.h>
    99#include <math.h>
     10#include <string.h>
    1011
    1112#include "jgraph.h"
     
    1920static double Pi;
    2021
    21 process_title(g)
    22 Graph g;
     22void process_label(Label l, Graph g, int adjust);
     23
     24void process_title(Graph g)
    2325{
    2426
     
    4446}
    4547
    46 process_legend(g)
    47 Graph g;
     48void process_label_max_n_mins(Label l, float len, float height)
     49{
     50  float xlen, ylen, xheight, yheight;
     51  float x, y;
     52
     53  xlen = len * cos(l->rotate * Pi / 180.00);
     54  ylen = height * cos((l->rotate + 90.0) * Pi / 180.00);
     55  xheight = len * sin(l->rotate * Pi / 180.00);
     56  yheight = height * sin((l->rotate + 90.0) * Pi / 180.00);
     57 
     58  x = l->x;
     59  y = l->y;
     60
     61  if (l->hj == 'c') {
     62    x -= xlen / 2.0;
     63    y -= xheight / 2.0;
     64  } else if (l->hj == 'r') {
     65    x -= xlen;
     66    y -= xheight;
     67  }
     68  if (l->vj == 'c') {
     69    x -= ylen / 2.0;
     70    y -= yheight / 2.0;
     71  } else if (l->vj == 't') {
     72    x -= ylen;
     73    y -= yheight;
     74  }
     75
     76  l->xmin = MIN(x, x + xlen);
     77  l->xmin = MIN(l->xmin, x + xlen + ylen);
     78  l->xmin = MIN(l->xmin, x + ylen);
     79
     80  l->ymin = MIN(y, y + xheight);
     81  l->ymin = MIN(l->ymin, y + yheight);
     82  l->ymin = MIN(l->ymin, y + xheight + yheight);
     83
     84  l->xmax = MAX(x, x + xlen);
     85  l->xmax = MAX(l->xmax, x + xlen + ylen);
     86  l->xmax = MAX(l->xmax, x + ylen);
     87
     88  l->ymax = MAX(y, y + xheight);
     89  l->ymax = MAX(l->ymax, y + yheight);
     90  l->ymax = MAX(l->ymax, y + xheight + yheight);
     91
     92}
     93
     94void process_legend(Graph g)
    4895{
    4996  Legend l;
     
    209256}
    210257
    211 float find_reasonable_hash_interval(a)
    212 Axis a;
     258float find_reasonable_hash_interval(Axis a)
    213259{
    214260  float s, d;
     
    238284}
    239285
    240 float find_reasonable_hash_start(a)
    241 Axis a;
     286float find_reasonable_hash_start(Axis a)
    242287{
    243288  int i;
     
    249294}
    250295
    251 int find_reasonable_precision(a)
    252 Axis a;
     296int find_reasonable_precision(Axis a)
    253297{
    254298  int i, b, b2, done;
     
    293337}
    294338
    295 int find_reasonable_minor_hashes(a)
    296 Axis a;
     339int find_reasonable_minor_hashes(Axis a)
    297340{
    298341  float d; 
     
    316359}
    317360
    318 process_axis1(a, g)
    319 Axis a;
    320 Graph g;
     361void process_axis1(Axis a, Graph g)
    321362{
    322363  float tmp;
     
    386427}
    387428
    388 process_axis2(a, g)
    389 Axis a;
    390 Graph g;
     429void process_axis2(Axis a, Graph g)
    391430{
    392431  float t1, t2, t3, minor_hashes, hloc, tmp;
     
    576615}
    577616
    578 process_label(l, g, adjust)
    579 Label l;
    580 Graph g;
    581 int adjust;
     617void process_label(Label l, Graph g, int adjust)
    582618{
    583619  float len, height;
     
    618654}
    619655   
    620 process_label_max_n_mins(l, len, height)
    621 Label l;
    622 float len;
    623 float height;
    624 {
    625   float xlen, ylen, xheight, yheight;
    626   float x, y;
    627 
    628   xlen = len * cos(l->rotate * Pi / 180.00);
    629   ylen = height * cos((l->rotate + 90.0) * Pi / 180.00);
    630   xheight = len * sin(l->rotate * Pi / 180.00);
    631   yheight = height * sin((l->rotate + 90.0) * Pi / 180.00);
    632  
    633   x = l->x;
    634   y = l->y;
    635 
    636   if (l->hj == 'c') {
    637     x -= xlen / 2.0;
    638     y -= xheight / 2.0;
    639   } else if (l->hj == 'r') {
    640     x -= xlen;
    641     y -= xheight;
    642   }
    643   if (l->vj == 'c') {
    644     x -= ylen / 2.0;
    645     y -= yheight / 2.0;
    646   } else if (l->vj == 't') {
    647     x -= ylen;
    648     y -= yheight;
    649   }
    650 
    651   l->xmin = MIN(x, x + xlen);
    652   l->xmin = MIN(l->xmin, x + xlen + ylen);
    653   l->xmin = MIN(l->xmin, x + ylen);
    654 
    655   l->ymin = MIN(y, y + xheight);
    656   l->ymin = MIN(l->ymin, y + yheight);
    657   l->ymin = MIN(l->ymin, y + xheight + yheight);
    658 
    659   l->xmax = MAX(x, x + xlen);
    660   l->xmax = MAX(l->xmax, x + xlen + ylen);
    661   l->xmax = MAX(l->xmax, x + ylen);
    662 
    663   l->ymax = MAX(y, y + xheight);
    664   l->ymax = MAX(l->ymax, y + yheight);
    665   l->ymax = MAX(l->ymax, y + xheight + yheight);
    666 
    667 }
    668 
    669 process_strings(g)
    670 Graph g;
     656void process_strings(Graph g)
    671657{
    672658  String s;
     
    677663}
    678664
    679 process_curve(c, g)
    680 Curve c;
    681 Graph g;
     665void process_curve(Curve c, Graph g)
    682666{
    683667  if (c->bezier && (c->npts < 4 || (c->npts % 3 != 1))) {
     
    705689}
    706690
    707 process_curves(g)
    708 Graph g;
     691void process_curves(Graph g)
    709692{
    710693  Curve c;
     
    713696  }
    714697}
     698
     699void process_label_extrema(Label l, Graph g)
     700{
     701  if (l->label == CNULL) return;
     702  g->yminval = MIN(g->yminval, l->ymin);
     703  g->ymaxval = MAX(g->ymaxval, l->ymax);
     704  g->xminval = MIN(g->xminval, l->xmin);
     705  g->xmaxval = MAX(g->xmaxval, l->xmax);
     706}
    715707 
    716 process_extrema(g)  /* This finds all the minval/maxvals for bbox calc */
    717 Graph g;
     708void process_extrema(Graph g)  /* Finds all the minval/maxvals for bbox calc */
    718709{
    719710  Curve c;
     
    764755}
    765756
    766 process_label_extrema(l, g)
    767 Label l;
    768 Graph g;
    769 {
    770   if (l->label == CNULL) return;
    771   g->yminval = MIN(g->yminval, l->ymin);
    772   g->ymaxval = MAX(g->ymaxval, l->ymax);
    773   g->xminval = MIN(g->xminval, l->xmin);
    774   g->xmaxval = MAX(g->xmaxval, l->xmax);
    775 }
    776 
    777 process_graph(g)
    778 Graph g;
     757void process_graph(Graph g)
    779758{
    780759  g->x_translate = intop(g->x_translate);
     
    791770}
    792771
    793 process_graphs(gs)
    794 Graphs gs;
     772void process_graphs(Graphs gs)
    795773{
    796774  Graphs the_g;
  • trunk/Jgraph/show.c

    r418 r420  
    1010#include "jgraph.h"
    1111
    12 static spaces(nsp)
    13 int nsp;
     12static void spaces(int nsp)
    1413{
    1514  while(nsp-- > 0) putchar(' ');
     
    4443}
    4544
    46 static show_mltiline(s)
    47 char *s;
     45static void show_mltiline(char *s)
    4846{
    4947  int i;
     
    5856}
    5957
    60 show_string(s)
    61 char *s;
     58void show_string(char *s)
    6259{
    6360  int i;
     
    7572   
    7673   
    77 show_label(l, nsp, g)
    78 Label l;
    79 int nsp;
    80 Graph g;
     74void show_label(Label l, int nsp, Graph g)
    8175{
    8276  spaces(nsp);
     
    9690    printf("lcolor %f %f %f\n", l->gray[0], l->gray[1], l->gray[2]);
    9791  }
    98   return;
    99 }
    100 
    101 show_lmark(l, nsp, g)
    102 Label l;
    103 int nsp;
    104 Graph g;
     92}
     93
     94void show_lmark(Label l, int nsp, Graph g)
    10595{
    10696  spaces(nsp); show_string(l->label);
     
    111101  spaces(nsp); printf("font %s ", l->font);
    112102               printf("fontsize %f\n", l->fontsize);
    113   return;
    114 }
    115 
    116 show_curve(c, nsp, g)
    117 Curve c;
    118 int nsp;
    119 Graph g;
     103}
     104
     105void show_curve(Curve c, int nsp, Graph g)
    120106{
    121107  Point p;
     
    252238}
    253239
    254 show_axis(a, nsp, g)
    255 Axis a;
    256 int nsp;
    257 Graph g;
     240void show_axis(Axis a, int nsp, Graph g)
    258241{
    259242  Axis other;
     
    343326}
    344327
    345 show_legend(l, nsp, g)
    346 Legend l;
    347 int nsp;
    348 Graph g;
     328void show_legend(Legend l, int nsp, Graph g)
    349329{
    350330  if (l->type == 'c') {
     
    363343}
    364344
    365 show_graph(g, nsp)
    366 Graph g;
    367 int nsp;
     345void show_graph(Graph g, int nsp)
    368346{
    369347
     
    395373}
    396374
    397 show_graphs(gs)
    398 Graphs gs;
     375void show_graphs(Graphs gs)
    399376{
    400377  Graphs the_g;
  • trunk/Jgraph/sin.c

    r418 r420  
     1#include <stdio.h>
    12#include <math.h>
    2      main()
     3     int main(void)
    34     {
    45       double x;
    56       for (x = -10.0; x < 10.0; x += .03)
    67         printf("%f %f\n", x, sin(x));
     8       return 0;
    79     }
  • trunk/Jgraph/token.c

    r418 r420  
    88#include <math.h>
    99#include <stdio.h>
     10#include <string.h>
    1011
    1112#ifdef LCC
     
    3637static int getnew = 1;
    3738static char oldchar = '\0';
    38 static oldcharvalid = 0;
     39static int oldcharvalid = 0;
    3940static char pipe = 0;
    4041static int eof = 0;
     
    6162#endif /*VMS*/
    6263
    63 set_input_file(s)
    64 char *s;
    65 {
    66   FILE *f;
     64void set_input_file(char *s)
     65{
    6766  Iostack n;
    6867
     
    9493}
    9594
    96 error_header()
     95void error_header()
    9796{
    9897  fprintf(stderr, "%s,%d: ", FILENAME, line);
     
    107106}
    108107
    109 ungettokenchar()
     108void ungettokenchar()
    110109{
    111110  oldcharvalid = 1;
     
    132131}
    133132
    134 get_comment()
     133void get_comment()
    135134{
    136135  if (eof) return;
     
    149148}
    150149
    151 static push_iostack(p)
    152 int p;
     150static void push_iostack(int p)
    153151{
    154152  Iostack n;
     
    178176}
    179177
    180 static pop_iostack()
     178static void pop_iostack()
    181179{
    182180  Iostack n;
     
    196194    n->stream = fopen(n->filename, "r");
    197195    if (n->stream == NULL) {
    198       fprintf(stderr, "Error: cannot open file \"%s\"\n", n->stream);
     196      fprintf(stderr, "Error: cannot open file \"%s\"\n", n->filename);
    199197      exit(1);
    200198    }
     
    211209}
    212210
    213 static nexttoken()
     211int getsystemstring(void);
     212
     213static void nexttoken()
    214214{
    215215  if (eof) return;
     
    256256  }
    257257  getnew = 1;
    258   return;
    259 }
    260 
    261 int getstring(s)
    262 char *s;
     258}
     259
     260int getstring(char *s)
    263261{
    264262  nexttoken();
     
    268266}
    269267
    270 int getint(i)
    271 int *i;
     268int getint(int *i)
    272269{
    273270  int j;
     
    283280}
    284281
    285 int getfloat(f)
    286 float *f;
     282int getfloat(float *f)
    287283{
    288284  int j;
     
    335331{
    336332  char c;
    337   int i, j, done, len, started;
     333  int i, done, len, started;
    338334  char *out_str;
    339335
     
    375371char *getlabel()
    376372{
    377   char c;
    378373  char *txt, *new;
    379   int i;
    380374
    381375  txt = getmultiline();
     
    416410}
    417411
    418 rejecttoken()
     412void rejecttoken(void)
    419413{
    420414  getnew = 0;
Note: See TracChangeset for help on using the changeset viewer.