/[pspp]/pspp/src/print.c
ViewVC logotype

Diff of /pspp/src/print.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by blp, Mon Oct 24 02:51:32 2005 UTC revision 1.23 by blp, Thu Nov 3 06:21:46 2005 UTC
# Line 80  enum Line 80  enum
80  /* PRINT, PRINT EJECT, WRITE private data structure. */  /* PRINT, PRINT EJECT, WRITE private data structure. */
81  struct print_trns  struct print_trns
82    {    {
     struct trns_header h;  
83      struct dfm_writer *writer;  /* Output file, NULL=listing file. */      struct dfm_writer *writer;  /* Output file, NULL=listing file. */
84      int options;                /* PRT_* bitmapped field. */      int options;                /* PRT_* bitmapped field. */
85      struct prt_out_spec *spec;  /* Output specifications. */      struct prt_out_spec *spec;  /* Output specifications. */
# Line 141  internal_cmd_print (int f) Line 140  internal_cmd_print (int f)
140    struct file_handle *fh = NULL;    struct file_handle *fh = NULL;
141    
142    /* Fill in prt to facilitate error-handling. */    /* Fill in prt to facilitate error-handling. */
   prt.h.proc = print_trns_proc;  
   prt.h.free = print_trns_free;  
143    prt.writer = NULL;    prt.writer = NULL;
144    prt.options = f;    prt.options = f;
145    prt.spec = NULL;    prt.spec = NULL;
# Line 209  internal_cmd_print (int f) Line 206  internal_cmd_print (int f)
206    /* Put the transformation in the queue. */    /* Put the transformation in the queue. */
207    trns = xmalloc (sizeof *trns);    trns = xmalloc (sizeof *trns);
208    memcpy (trns, &prt, sizeof *trns);    memcpy (trns, &prt, sizeof *trns);
209    add_transformation ((struct trns_header *) trns);    add_transformation (print_trns_proc, print_trns_free, trns);
210    
211    return CMD_SUCCESS;    return CMD_SUCCESS;
212    
213   error:   error:
214    print_trns_free ((struct trns_header *) & prt);    print_trns_free (&prt);
215    return CMD_FAILURE;    return CMD_FAILURE;
216  }  }
217    
# Line 640  fixed_parse_compatible (void) Line 637  fixed_parse_compatible (void)
637    
638  /* Destroy a format list and, optionally, all its sublists. */  /* Destroy a format list and, optionally, all its sublists. */
639  static void  static void
640  destroy_fmt_list (struct fmt_list * f, int recurse)  destroy_fmt_list (struct fmt_list *f, int recurse)
641  {  {
642    struct fmt_list *next;    struct fmt_list *next;
643    
# Line 657  destroy_fmt_list (struct fmt_list * f, i Line 654  destroy_fmt_list (struct fmt_list * f, i
654     FORTRAN-like format specifications, like 4(F10,2X)) into the     FORTRAN-like format specifications, like 4(F10,2X)) into the
655     structure prt. */     structure prt. */
656  static int  static int
657  dump_fmt_list (struct fmt_list * f)  dump_fmt_list (struct fmt_list *f)
658  {  {
659    int i;    int i;
660    
# Line 899  alloc_line (void) Line 896  alloc_line (void)
896    
897  /* Performs the transformation inside print_trns T on case C. */  /* Performs the transformation inside print_trns T on case C. */
898  static int  static int
899  print_trns_proc (struct trns_header * trns, struct ccase * c,  print_trns_proc (void *trns_, struct ccase *c, int case_num UNUSED)
                  int case_num UNUSED)  
900  {  {
901    /* Transformation. */    /* Transformation. */
902    struct print_trns *t = (struct print_trns *) trns;    struct print_trns *t = trns_;
903    
904    /* Iterator. */    /* Iterator. */
905    struct prt_out_spec *i;    struct prt_out_spec *i;
# Line 976  print_trns_proc (struct trns_header * tr Line 972  print_trns_proc (struct trns_header * tr
972    
973  /* Frees all the data inside print_trns T.  Does not free T. */  /* Frees all the data inside print_trns T.  Does not free T. */
974  static void  static void
975  print_trns_free (struct trns_header * t)  print_trns_free (void *prt_)
976  {  {
977    struct print_trns *prt = (struct print_trns *) t;    struct print_trns *prt = prt_;
978    struct prt_out_spec *i, *n;    struct prt_out_spec *i, *n;
979    
980    for (i = prt->spec; i; i = n)    for (i = prt->spec; i; i = n)
# Line 1003  print_trns_free (struct trns_header * t) Line 999  print_trns_free (struct trns_header * t)
999    if (prt->writer != NULL)    if (prt->writer != NULL)
1000      dfm_close_writer (prt->writer);      dfm_close_writer (prt->writer);
1001    free (prt->line);    free (prt->line);
1002      free (prt);
1003  }  }
1004    
1005  /* PRINT SPACE. */  /* PRINT SPACE. */
# Line 1010  print_trns_free (struct trns_header * t) Line 1007  print_trns_free (struct trns_header * t)
1007  /* PRINT SPACE transformation. */  /* PRINT SPACE transformation. */
1008  struct print_space_trns  struct print_space_trns
1009  {  {
   struct trns_header h;  
   
1010    struct dfm_writer *writer;    /* Output data file. */    struct dfm_writer *writer;    /* Output data file. */
1011    struct expression *e;         /* Number of lines; NULL=1. */    struct expression *e;         /* Number of lines; NULL=1. */
1012  }  }
# Line 1066  cmd_print_space (void) Line 1061  cmd_print_space (void)
1061      writer = NULL;      writer = NULL;
1062        
1063    t = xmalloc (sizeof *t);    t = xmalloc (sizeof *t);
   t->h.proc = print_space_trns_proc;  
   if (e)  
     t->h.free = print_space_trns_free;  
   else  
     t->h.free = NULL;  
1064    t->writer = writer;    t->writer = writer;
1065    t->e = e;    t->e = e;
1066    
1067    add_transformation ((struct trns_header *) t);    add_transformation (print_space_trns_proc, print_space_trns_free, t);
1068    return CMD_SUCCESS;    return CMD_SUCCESS;
1069  }  }
1070    
1071  static int  static int
1072  print_space_trns_proc (struct trns_header * trns, struct ccase * c,  print_space_trns_proc (void *t_, struct ccase *c,
1073                         int case_num UNUSED)                         int case_num UNUSED)
1074  {  {
1075    struct print_space_trns *t = (struct print_space_trns *) trns;    struct print_space_trns *t = t_;
1076    double n = 1.;    double n = 1.;
1077    
1078    if (t->e)    if (t->e)
# Line 1118  print_space_trns_proc (struct trns_heade Line 1108  print_space_trns_proc (struct trns_heade
1108  }  }
1109    
1110  static void  static void
1111  print_space_trns_free (struct trns_header * trns)  print_space_trns_free (void *trns_)
1112  {  {
1113    expr_free (((struct print_space_trns *) trns)->e);    struct print_space_trns *trns = trns_;
1114      expr_free (trns->e);
1115      free (trns);
1116  }  }

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26