PIPS
maind.c
Go to the documentation of this file.
1 /*
2 
3  $Id: maind.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* This file comes directly from maind.c, from which main()
28  * has been removed. All globals definitions has also been removed.
29  * This file is necessary for compilation.
30  * AL 9/12/93
31  */
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <string.h>
35 #include <ctype.h>
36 #include "pip__type.h"
37 #include "pip__sol.h"
38 #include "pip__tab.h"
39 #include <sys/types.h>
40 
41 #define INLENGTH 1024
42 extern long int cross_product, limit;
43 extern int allocation, comptage;
44 extern char inbuff[];
45 extern int inptr, proviso, verbose;
46 extern FILE *dump;
47 extern char dump_name[];
48 
49 
51 
52 int dgetc(foo)
53 FILE *foo;
54 {
55  char *p;
56  if(inptr >= proviso)
57  {p = fgets(inbuff, INLENGTH, foo);
58  if(p == NULL) return EOF;
59  proviso = strlen(inbuff);
60  if(INLENGTH - proviso <= 1) {
61  fprintf(stderr, "troncature %d\n",proviso);
62  exit(12);
63  }
64  inptr = 0;
65  if(verbose > 0) fprintf(dump, "-- %s", inbuff);
66  }
67  return inbuff[inptr++];
68 }
69 
70 int dscanf(foo, format, val)
71 FILE *foo;
72 char * format;
73 Entier * val;
74 {
75  char * p;
76  int c;
77  for(;inptr < proviso; inptr++)
78  if(inbuff[inptr] != ' ' && inbuff[inptr] != '\n' && inbuff[inptr] != '\t')
79  break;
80  while(inptr >= proviso)
81  {p = fgets(inbuff, 256, foo);
82  if(p == NULL) return EOF;
83  proviso = strlen(inbuff);
84  if(verbose > 0) {
85  fprintf(dump, ".. %s", inbuff);
86  fflush(dump);
87  }
88  for(inptr = 0; inptr < proviso; inptr++)
89  if(inbuff[inptr] != ' ' && inbuff[inptr] != '\n' && inbuff[inptr] != '\t')
90  break;
91  }
92  if(sscanf(inbuff+inptr, format, val) != 1) return -1;
93  for(; inptr < proviso; inptr++)
94  if((c = inbuff[inptr]) != '-' && !isdigit(c)) break;
95  return 0;
96 }
97 
98 void balance(foo, bar)
99 FILE *foo, *bar;
100 {
101  int level = 0;
102  int c;
103  while((c = dgetc(foo)) != EOF)
104  {putc(c, bar);
105  switch(c)
106  {case '(' : level++; break;
107  case ')' : if(--level == 0) return;
108  }
109  }
110 }
111 
112 void escape(foo, bar, level)
113 FILE * foo, * bar;
114 int level;
115 {int c;
116  while((c = dgetc(foo)) != EOF)
117  switch(c)
118  {case '(' : level ++; break;
119  case ')' : if(--level == 0)
120  { fprintf(bar, "\nerror\n)\n");
121  return;
122  }
123  }
124 }
125 
int comptage
Definition: maind.c:43
int verbose
Definition: maind.c:45
int dgetc(FILE *foo)
Definition: maind.c:52
int inptr
Definition: pip.c:94
void balance(FILE *foo, FILE *bar)
Definition: maind.c:98
int dscanf(FILE *foo, char *format, Entier *val)
Definition: maind.c:70
int proviso
Definition: maind.c:45
long int limit
Definition: maind.c:42
Tableau * expanser()
int allocation
External variables for direct call to PIP.
Definition: pip.c:92
#define INLENGTH
This file comes directly from maind.c, from which main() has been removed.
Definition: maind.c:41
char inbuff[]
Definition: pip.c:93
char dump_name[]
Definition: pip.c:98
FILE * dump
Should not be used : put here for Pip copatibility.
Definition: pip.c:97
long int cross_product
Definition: pip.c:91
void escape(FILE *foo, FILE *bar, int level)
Definition: maind.c:112
#define exit(code)
Definition: misc-local.h:54
#define Entier
Definition: pip__type.h:24
#define level
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Definition: pip__tab.h:48