Changeset e08f69 in git


Ignore:
Timestamp:
Aug 25, 1999, 5:26:02 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
abcc453829974f82c44759593b2abe1da573a348
Parents:
2762d8f63b36cec5598227c07c50ae666e0dcd1a
Message:
* Makefile: new target ESingular
* emacs.cc: implementation of ESingular
* feCmdLineOptions.cc: isolated CmdLineOptions stuff


git-svn-id: file:///usr/local/Singular/svn/trunk@3547 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • Singular/Makefile.in

    r2762d8f re08f69  
    6767CXXSOURCES=grammar.cc scanner.cc algmap.cc attrib.cc binom.cc clapconv.cc \
    6868    clapmem.cc clapsing.cc claptmpl.cc cntrlc.cc \
    69     extra.cc febase.cc feread.cc fehelp.cc feResource.cc \
     69    extra.cc febase.cc feread.cc fehelp.cc feResource.cc feCmdLineOptions.cc\
    7070    ffields.cc hdegree.cc hilb.cc hutil.cc \
    7171    ideals.cc intvec.cc iparith.cc \
     
    246246        ${LEX} -I -Pyylp -olibparse.cc libparse.l
    247247
     248ESingular: feResource.cc mod2.h feCmdLineOptions.cc version.h emacs.cc
     249        ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${DEFS} -o ESingular emacs.cc
     250
    248251src: scanner.cc grammar.h grammar.cc libparse.cc spSpolyLoop.inc
    249252
     
    269272install: all installbin installslib
    270273
    271 installbin: Singular libparse
     274installbin: Singular libparse ESingular
    272275        ${MKINSTALLDIRS} ${bindir}
    273276        ${INSTALL_PROGRAM} Singular ${bindir}/Singular-${SINGULAR_VERSION}
    274277        ${INSTALL_PROGRAM} libparse ${bindir}/libparse
     278        ${INSTALL_PROGRAM} ESingular ${bindir}/ESingular
    275279        chmod a+x ${bindir}/Singular-${SINGULAR_VERSION}
    276280        rm -f ${bindir}/Singular
     
    323327        echo "#define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h
    324328        echo "#define MAKE_DISTRIBUTION " >> version.h
    325         ${MAKE} Singular
    326         strip Singular
     329        ${MAKE} Singular ESingular
     330        strip Singular ESingular
    327331        ${INSTALL} -s Singular Singular-bindist
     332        ${INSTALL} -s ESingular ESingular-bindist
    328333        echo "#define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h
    329334
     
    331336        echo "#define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h
    332337        echo "#define MAKE_DISTRIBUTION " >> version.h
    333         ${MAKE} Singular-static
    334         strip Singular-static
     338        ${MAKE} Singular-static ESingular
     339        strip Singular-static ESingular
    335340        mv Singular-static Singular-static-bindist
     341        ${INSTALL} -s ESingular ESingular-bindist
    336342        echo "#define SINGULAR_VERSION_ID " `date '+%y%m%d%H'` >version.h
    337343
  • Singular/feResource.cc

    r2762d8f re08f69  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: feResource.cc,v 1.7 1999-08-16 15:09:47 obachman Exp $ */
     4/* $Id: feResource.cc,v 1.8 1999-08-25 15:26:02 obachman Exp $ */
    55/*
    66* ABSTRACT: management of resources
     
    1010
    1111#include "mod2.h"
     12#include "version.h"
     13#ifndef ESINGULAR
    1214#include "mmemory.h"
    1315#include "febase.h"
    14 #include "version.h"
     16extern "C" char* find_executable(const char* argv0);
     17#endif
    1518
    1619// define RESOURCE_DEBUG for chattering about resource management
     
    7376  {"ManualUrl", 'u',    feResUrl,   "SINGULAR_URL",         "http://www.mathematik.uni-kl.de/~zca/Singular/Manual/"S_VERSION1,    ""},
    7477  {"EmacsDir",  'e',    feResDir,   "SINGULAR_EMACS_DIR",   "%r/emacs",             ""},
    75 #if !defined(WINNT) && ! defined(macintosh)
     78#if !defined(macintosh)
    7679  {"netscape",  'N',    feResBinary,"NETSCAPE",             "%b/netscape",          ""},
    7780  {"info",      'I',    feResBinary,"INFO",                 "%b/info",              ""},
     
    7982  {"xterm",     'X',    feResBinary,"XTERM",                "%b/xterm",             ""},
    8083  {"Path",      'p',    feResPath,  NULL,                   "%b;$PATH",         ""},
    81 #endif // !defined(WINNT) && ! defined(macintosh)
     84#endif // ! defined(macintosh)
     85 
     86#ifdef ESINGULAR
     87  {"emacs",    'E',    feResBinary, "EMACS",               "%b/emacs",              ""},
     88  {"SingularEmacs", 'M',    feResBinary, "SINGULAR_EMACS",  "%b/Singular",           ""},
     89  {"EmacsLoad",'l',    feResFile,   "SINGULAR_EMACS_LOAD", "%e/.singular-emacs",             ""},
     90#endif
    8291  {NULL, 0, feResUndef, NULL, NULL, NULL}, // must be the last record
    8392};
     
    104113static feResourceConfig feGetResourceConfig(const char* key);
    105114static char* feResource(feResourceConfig config, int warn);
     115static char* feResourceDefault(feResourceConfig config);
    106116static char* feInitResource(feResourceConfig config, int warn);
    107117static char* feGetExpandedExecutable();
     
    112122static void mystrcpy(char* d, char* s);
    113123static char* feSprintf(char* s, const char* fmt, int warn = -1);
    114 extern "C" char* find_executable(const char* argv0);
    115124#if defined(WINNT) && defined(__GNUC__)
    116125// utility function of Cygwin32:
     
    123132 *
    124133 *****************************************************************/
    125 char* feResource(const char id, int warn)
     134char* feResource(const char id, int warn = -1)
    126135{
    127136  return feResource(feGetResourceConfig(id), warn);
    128137}
    129138
    130 char* feResource(const char* key, int warn)
     139char* feResource(const char* key, int warn = -1)
    131140{
    132141  return feResource(feGetResourceConfig(key), warn);
     142}
     143
     144char* feResourceDefault(const char id)
     145{
     146  return feResourceDefault(feGetResourceConfig(id));
     147}
     148
     149char* feResourceDefault(const char* key)
     150{
     151  return feResourceDefault(feGetResourceConfig(key));
    133152}
    134153
     
    218237}
    219238
     239static char* feResourceDefault(feResourceConfig config)
     240{
     241  char* value = (char*) AllocL(MAXRESOURCELEN);
     242  feSprintf(value, config->fmt, -1);
     243  return value;
     244}
     245
    220246static char* feInitResource(feResourceConfig config, int warn)
    221247{
     
    322348  if (warn > 0 || (warn < 0 && config->value != NULL))
    323349  {
    324     Warn("Could not get %s.", config->key);
    325     Warn("Either set environment variable %s to the location of %s",
     350    Warn("Could not get %s. ", config->key);
     351    Warn("Either set environment variable %s to the location of %s ",
    326352         config->env, config->key);
    327353    feSprintf(value, config->fmt, warn);
     
    661687}
    662688   
    663 void feStringAppendResources(int warn)
     689void feStringAppendResources(int warn = -1)
    664690{
    665691  int i = 0;
  • Singular/find_exec.c

    r2762d8f re08f69  
    1919#include <strings.h>
    2020
     21#ifndef ESINGULAR
    2122#include "mmemory.h"
     23#endif
     24
    2225
    2326#ifndef MAXPATHLEN
  • Singular/tesths.cc

    r2762d8f re08f69  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: tesths.cc,v 1.68 1999-08-13 11:21:44 Singular Exp $ */
     4/* $Id: tesths.cc,v 1.69 1999-08-25 15:26:02 obachman Exp $ */
    55
    66/*
     
    3131#include <factory.h>
    3232#endif
    33 #include "getopt.h"
    34 
    35 // define the long option names here
    36 #define LON_BATCH           "batch"
    37 #define LON_BROWSER         "browser"
    38 #define LON_EXECUTE         "execute"
    39 #define LON_EMACS           "emacs"
    40 #define LON_ECHO            "echo"
    41 #define LON_HELP            "help"
    42 #define LON_RANDOM          "random"
    43 #define LON_QUIET           "quiet"
    44 #define LON_NO_TTY          "no-tty"
    45 #define LON_USER_OPTION     "user-option"
    46 #define LON_VERSION         "verbose"
    47 #define LON_MIN_TIME        "min-time"
    48 #define LON_NO_STDLIB       "no-stdlib"
    49 #define LON_NO_RC           "no-rc"
    50 #define LON_TICKS_PER_SEC   "ticks-per-sec"
    51 #define LON_TCLMODE         "tclmode"
    52 #define LON_MP_PORT         "MPport"
    53 #define LON_MP_HOST         "MPhost"
    54 #define LON_NO_WARN         "no-warn"
    55 #define LON_NO_OUT          "no-out"
    56 #define LON_SDB             "sdb"
    57 // undocumented options
    58 #ifdef HAVE_MPSR
    59 #define LON_MP_TRANSP       "MPtransp"
    60 #define LON_MP_MODE         "MPmode"
    61 #endif
    62 
    63 #define LONG_OPTION_RETURN 13
    64 static struct option longopts[] =
    65 {
    66 #ifdef HAVE_MPSR
    67   {LON_BATCH,             0,  0,  'b'},
    68 #endif
    69   {LON_EXECUTE,           1,  0,  'c'},
    70   {LON_SDB,               0,  0,  'd'},
    71   {LON_ECHO,              2,  0,  'e'},
    72   {LON_HELP,              0,  0,  'h'},
    73   {LON_QUIET,             0,  0,  'q'},
    74   {LON_RANDOM,            1,  0,  'r'},
    75   {LON_NO_TTY,            0,  0,  't'},
    76   {LON_USER_OPTION,       1,  0,  'u'},
    77   {LON_VERSION,           0,  0,  'v'},
    78 #ifdef HAVE_TCL
    79   {LON_TCLMODE,           0,  0,  'x'},
    80 #endif
    81   {LON_BROWSER,           1,  0,  LONG_OPTION_RETURN},
    82   {LON_NO_STDLIB,         0,  0,  LONG_OPTION_RETURN},
    83   {LON_NO_RC,             0,  0,  LONG_OPTION_RETURN},
    84   {LON_NO_WARN,           0,  0,  LONG_OPTION_RETURN},
    85   {LON_NO_OUT,            0,  0,  LONG_OPTION_RETURN},
    86   {LON_MIN_TIME,          1,  0,  LONG_OPTION_RETURN},
    87 #ifdef HAVE_MPSR
    88   {LON_MP_PORT,           1,  0,  LONG_OPTION_RETURN},
    89   {LON_MP_HOST,           1,  0,  LONG_OPTION_RETURN},
    90 #endif
    91   {LON_TICKS_PER_SEC,     1,  0,  LONG_OPTION_RETURN},
    92 // undocumented options
    93   {LON_EMACS,             0,  0,  LONG_OPTION_RETURN},
    94 #ifdef HAVE_MPSR
    95   {LON_MP_TRANSP,         1,  0,  LONG_OPTION_RETURN},
    96   {LON_MP_MODE,           1,  0,  LONG_OPTION_RETURN},
    97 #endif
    98 // terminator
    99   { 0, 0, 0, 0 }
    100 };
    101 // #define SHORT_OPTS_STRING "bc:e::hqr:tu:v"
    102 #define SHORT_OPTS_STRING "bdhqtvxec:r:u:"
    103 
    104 struct sing_option
    105 {
    106   const char*   name;    // as in option
    107 
    108   const char*   arg_name;// name of argument, if has_arg > 0
    109   const char*   help;    // (short) help string
    110   char*         val;     // (default) value of option: 0: not set 1:set
    111                          // string:"" if has_arg > 0
    112 };
    113 
    114 // mention only documented options here
    115 // or let help string start with // then option is like undocumented
    116 static struct sing_option sing_longopts[] =
    117 {
    118 #ifdef HAVE_MPSR
    119   {LON_BATCH,       0,          "Run in MP batch mode",                                 0},
    120 #endif
    121   {LON_BROWSER,     "BROWSER",  "Display help in BROWSER ([x,tk]info, netscape)",       ""},
    122   {LON_HELP,        0,          "Print help message and exit",                          0},
    123   {LON_QUIET,       0,          "Do not print start-up banner and library load messages", 0},
    124   {LON_SDB,         0,          "Enable sdb debugger (experimental)",            0},
    125   {LON_NO_TTY,      0,          "Do not redefine the terminal characteristics",         0},
    126   {LON_VERSION,     0,          "Print extended version and configuration info",        0},
    127 #ifdef HAVE_TCL
    128   {LON_TCLMODE,     0,          "Run in TCL mode, i.e., with TCL user interface",       0},
    129 #endif
    130   {LON_ECHO,        "VAL",      "Set value of variable `echo' to (integer) VAL",        ""},
    131   {LON_EXECUTE,     "STRING",   "Execute STRING on start-up",                           ""},
    132   {LON_RANDOM,      "SEED",     "Seed random generator with integer (integer) SEED",    ""},
    133   {LON_USER_OPTION, "STRING",   "Return STRING on `system(\"--user-option\")'",         ""},
    134   {LON_NO_STDLIB,   0,          "Do not load `standard.lib' on start-up",               0},
    135   {LON_NO_RC,       0,          "Do not execute `.singularrc' file on start-up",        0},
    136   {LON_NO_WARN,     0,          "Do not display warning messages",        0},
    137   {LON_NO_OUT,      0,          "Suppress all output",        0},
    138   {LON_MIN_TIME,    "SECS",     "Do not display times smaller than SECS (in seconds)",  "0.5"},
    139 #ifdef HAVE_MPSR
    140   {LON_MP_PORT,     "PORT",     "Use PORT number for MP conections",                    ""},
    141   {LON_MP_HOST,     "HOST",     "Use HOST for MP connections",                          ""},
    142 #endif
    143   {LON_TICKS_PER_SEC, "TICKS",    "Sets unit of timer to TICKS per second",             "1"},
    144   // option whose help should not clutter up the normal help stuff
    145   {LON_EMACS,       0,          "// Support singular-emacs mode",                          0},
    146   { 0, 0, 0, 0 }
    147 };
    148 
    149 static struct sing_option* mainGetSingOption(const char* name)
    150 {
    151   int i = 0;
    152   while (sing_longopts[i].name != 0)
    153   {
    154     if (strcmp(name, sing_longopts[i].name) == 0)
    155       return &(sing_longopts[i]);
    156     i++;
    157   }
    158   return NULL;
    159 }
    160 
    161 void mainSetSingOptionValue(const char* name, char* value)
    162 {
    163   sing_option* sopt = mainGetSingOption(name);
    164   if (sopt != NULL)
    165   {
    166     sopt->val = value;
    167   }
    168 }
    169 
    170 char* mainGetSingOptionValue(const char* name)
    171 {
    172   sing_option* sopt = mainGetSingOption(name);
    173   if (sopt!=NULL)
    174     return sopt->val;
    175   return NULL;
    176 }
    177 
    178 
    179 // Prints help message
    180 static void mainHelp(const char* name)
    181 {
    182   int i = 0;
    183   struct sing_option *sopt;
    184   char tmp[20];
    185 
    186   printf("Singular version %s -- a CAS for polynomial computations. Usage:\n", S_VERSION1);
    187   printf("   %s [options] [file1 [file2 ...]]\n", name);
    188   printf("Options:\n");
    189 
    190   while (longopts[i].name != 0)
    191   {
    192     sopt = mainGetSingOption(longopts[i].name);
    193     if (sopt != NULL && sopt->help != NULL
    194 #ifdef NDEBUG
    195         && *(sopt->help) != '/'
    196 #endif
    197         )
    198     {
    199       if (longopts[i].has_arg > 0)
    200       {
    201         if  (longopts[i].has_arg > 1)
    202           sprintf(tmp, "%s[=%s]", longopts[i].name, sopt->arg_name);
    203         else
    204           sprintf(tmp, "%s=%s", longopts[i].name, sopt->arg_name);
    205 
    206         printf(" %c%c --%-19s %s\n",
    207                (longopts[i].val != 0 ? '-' : ' '),
    208                (longopts[i].val != 0 ? longopts[i].val : ' '),
    209                tmp,
    210                sopt->help);
    211       }
    212       else
    213       {
    214         printf(" %c%c --%-19s %s\n",
    215                (longopts[i].val != 0 ? '-' : ' '),
    216                (longopts[i].val != 0 ? longopts[i].val : ' '),
    217                longopts[i].name,
    218                sopt->help);
    219       }
    220     }
    221 #ifndef NDEBUG
    222     else
    223       printf("--%s Undocumented\n", longopts[i].name);
    224 #endif
    225     i++;
    226   }
    227 
    228   printf("\nFor more information, type `help;' from within Singular or visit\n");
    229   printf("http://www.mathematik.uni-kl.de/~zca/Singular or consult the\n");
    230   printf("Singular manual (available as on-line info or printed manual).\n");
    231 }
    232 
    233 // Prints usage message
    234 static void mainUsage(char* argv0)
    235 {
    236   printf("Use `%s --help' for a complete list of options\n", argv0);
    237 }
    238 
    239 #ifndef NDEBUG
    240 void mainOptionValues()
    241 {
    242   int i = 0;
    243   struct sing_option *sopt;
    244 
    245   while (longopts[i].name != 0)
    246   {
    247     sopt = mainGetSingOption(longopts[i].name);
    248     if (sopt != NULL)
    249     {
    250       if (sopt->val == NULL || sopt->val == (char*) 1)
    251         Print("// --%-10s %d\n", sopt->name, sopt->val);
    252       else
    253         Print("// --%-10s %s\n", sopt->name, sopt->val);
    254     }
    255     else
    256       Print("// --%s Undocumented \n", longopts[i].name);
    257     i++;
    258   }
    259 }
    260 #endif // NDEBUG
    261 
    262 BOOLEAN mainGetSingOptionValue(const char* name, char** val)
    263 {
    264   sing_option* sopt = mainGetSingOption(name);
    265   if (sopt == NULL)
    266   {
    267     *val = NULL;
    268     return FALSE;
    269   }
    270   else
    271   {
    272     *val = sopt->val;
    273     return TRUE;
    274   }
    275 }
    276 
     33
     34#include "feCmdLineOptions.cc"
    27735/*0 implementation*/
    27836int main(          /* main entry to Singular */
Note: See TracChangeset for help on using the changeset viewer.