feOptGen.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /*
5 * ABSTRACT: Implementation of option business
6 */
7 
8 #include <string.h>
9 #include <stdlib.h>
10 
11 
12 
13 
14 #include <kernel/mod2.h>
15 
16 #define FE_OPT_STRUCTURE
17 
18 #include "feOptGen.h"
19 
20 #include "fehelp.h"
21 
22 const char SHORT_OPTS_STRING[] = "bdhqstvxec:r:u:";
23 
24 //////////////////////////////////////////////////////////////
25 //
26 // Generation of feOptIndex
27 //
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <stdlib.h>
31 int main()
32 {
33  FILE* fd;
34 #ifdef ESINGULAR
35  fd = fopen("feOptES.xx", "w");
36 #elif defined(TSINGULAR)
37  fd = fopen("feOptTS.xx", "w");
38 #else
39  fd = fopen("feOpt.xx", "w");
40 #endif
41 
42  if (fd == NULL) exit(1);
43 
44  int i = 0;
45 
46  fputs("typedef enum\n{\n", fd);
47 
48  while (feOptSpec[i].name != NULL)
49  {
50  const char* name = feOptSpec[i].name;
51  fputs("FE_OPT_", fd);
52  while (*name != 0)
53  {
54  if (*name == '-')
55  {
56  putc('_', fd);
57  }
58  else if (*name >= 97 && *name <= 122)
59  {
60  putc(*name - 32, fd);
61  }
62  else
63  {
64  putc(*name, fd);
65  }
66  name++;
67  }
68  if (i == 0)
69  {
70  fputs("=0", fd);
71  }
72  i++;
73  fputs(",\n ", fd);
74  }
75 
76  fprintf(fd, "FE_OPT_UNDEF\n} feOptIndex;\n");
77  fclose(fd);
78 #ifdef ESINGULAR
79  rename("feOptES.xx", "feOptES.inc");
80 #elif defined(TSINGULAR)
81  rename("feOptTS.xx", "feOptTS.inc");
82 #else
83  rename("feOpt.xx", "feOpt.inc");
84 #endif
85  return(0);
86 }
int status int fd
Definition: si_signals.h:59
const char SHORT_OPTS_STRING[]
Definition: feOptGen.cc:22
char * name
Definition: fegetopt.h:83
struct fe_option feOptSpec[]
int i
Definition: cfEzgcd.cc:123
char name(const Variable &v)
Definition: factory.h:178
#define NULL
Definition: omList.c:10
int main()
Definition: feOptGen.cc:31