Project

General

Profile

« Previous | Next » 

Revision f0a067e9

Added by Pierre-Loïc Garoche almost 3 years ago

Better production of trace files.
By default traces are not produced. Requires the option -t to produce them

View differences:

include/io_frontend.c
6 6
int ISATTY;
7 7

  
8 8
/* Standard Input procedures **************/
9
_Bool _get_bool(FILE* file, char* n){
9
_Bool _get_bool(char* n){
10 10
   char b[512];
11 11
   int r = 0;
12 12
   int s = 1;
......
22 22
      if((c == '0') || (c == 'f') || (c == 'F')) r = 0;
23 23
      if((c == '1') || (c == 't') || (c == 'T')) r = 1;
24 24
   } while((s != 1) || (r == -1));
25
   fprintf(file, "%i\n",r);
26 25
   return (_Bool)r;
27 26
}
28 27

  
29
int _get_int(FILE* file, char* n){
28
int _get_int(char* n){
30 29
   char b[512];
31 30
   int r;
32 31
   int s = 1;
......
38 37
      if(scanf("%s", b)==EOF) exit(0);
39 38
      s = sscanf(b, "%d", &r);
40 39
   } while(s != 1);
41
   fprintf(file, "%d\n", r);
42 40
   return r;
43 41
}
44 42

  
45
double _get_double(FILE* file, char* n){
43
double _get_double(char* n){
46 44
   char b[512];
47 45
   double r;
48 46
   int s = 1;
......
54 52
      if(scanf("%s", b)==EOF) exit(0);
55 53
      s = sscanf(b, "%lf", &r);
56 54
   } while(s != 1);
57
   fprintf(file, "%f\n", r);
58 55
   return r;
59 56
}
60 57
/* Standard Output procedures **************/
61
void _put_bool(FILE* file, char* n, _Bool _V){
58
void _put_bool(char* n, _Bool _V){
62 59
  if(ISATTY) {
63 60
    printf("%s = ", n);
64 61
  } else {
......
66 63
  };
67 64
  printf("'%i' ", (_V)? 1 : 0);
68 65
  printf("\n");
69
  fprintf(file, "%i\n", _V);
70
  fflush(file);
71 66
}
72
void _put_int(FILE* file, char* n, int _V){
67
void _put_int(char* n, int _V){
73 68
  if(ISATTY) {
74 69
    printf("%s = ", n);
75 70
  } else {
......
77 72
  };
78 73
  printf("'%d' ", _V);
79 74
  printf("\n");
80
  fprintf(file, "%d\n", _V);
81
  fflush(file);
82 75
}
83 76

  
84
void _put_float(FILE* file, char* n, float _V, int PREC){
77
void _put_float(char* n, float _V, int PREC){
85 78
  if(ISATTY) {
86 79
    printf("%s = ", n);
87 80
  } else {
......
89 82
  };
90 83
  printf("'%.*f' ", PREC, _V);
91 84
  printf("\n");
92
  fprintf(file, "%.*f\n", PREC, _V);
93
  fflush(file);
94 85
}
95 86

  
96
void _put_double(FILE* file, char* n, double _V, int PREC){
87
void _put_double(char* n, double _V, int PREC){
97 88
  if(ISATTY) {
98 89
    printf("%s = ", n);
99 90
  } else {
......
101 92
  };
102 93
  printf("'%.*f' ", PREC, _V);
103 94
  printf("\n");
104
  fprintf(file, "%.*f\n", PREC, _V);
105
  fflush(file);
106 95
}

Also available in: Unified diff