source: git/Singular/feOptGen.cc @ 91ecf18

spielwiese
Last change on this file since 91ecf18 was 762407, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
config.h is for sources files only FIX: config.h should only be used by source (not from inside kernel/mod2.h!) NOTE: each source file should better include mod2.h right after config.h, while headers should better not include mod2.h.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id$ */
5/*
6* ABSTRACT: Implementation of option buisness
7*/
8
9#include <string.h>
10#include <stdlib.h>
11
12#include "config.h"
13#include <kernel/mod2.h>
14
15#define FE_OPT_STRUCTURE
16
17#include "feOptGen.h"
18
19#include "fehelp.h"
20
21const char SHORT_OPTS_STRING[] = "bdhqstvxec:r:u:";
22
23//////////////////////////////////////////////////////////////
24//
25// Generation of feOptIndex
26//
27#include <stdio.h>
28#include <unistd.h>
29#include <stdlib.h>
30int main()
31{
32  FILE* fd;
33#ifdef ESINGULAR
34  fd = fopen("feOptES.xx", "w");
35#elif defined(TSINGULAR)
36  fd = fopen("feOptTS.xx", "w");
37#else
38  fd = fopen("feOpt.xx", "w");
39#endif
40
41  if (fd == NULL) exit(1);
42
43  int i = 0;
44
45  fputs("typedef enum\n{\n", fd);
46
47  while (feOptSpec[i].name != NULL)
48  {
49    const char* name = feOptSpec[i].name;
50    fputs("FE_OPT_", fd);
51    while (*name != 0)
52    {
53      if (*name == '-')
54      {
55        putc('_', fd);
56      }
57      else if (*name >= 97 && *name <= 122)
58      {
59        putc(*name - 32, fd);
60      }
61      else
62      {
63        putc(*name, fd);
64      }
65      name++;
66    }
67    if (i == 0)
68    {
69      fputs("=0", fd);
70    }
71    i++;
72    fputs(",\n  ", fd);
73  }
74
75  fprintf(fd, "FE_OPT_UNDEF\n} feOptIndex;\n");
76  fclose(fd);
77#ifdef ESINGULAR
78  rename("feOptES.xx", "feOptES.inc");
79#elif defined(TSINGULAR)
80  rename("feOptTS.xx", "feOptTS.inc");
81#else
82  rename("feOpt.xx", "feOpt.inc");
83#endif
84  return(0);
85}
Note: See TracBrowser for help on using the repository browser.