Changeset 854405 in git


Ignore:
Timestamp:
Mar 26, 2012, 1:54:25 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
131ab788024317fd3dc0c6dc15caa89df0976ad4
Parents:
a10fdfe4d442bc04f32d34fcfb152911e9097218
Message:
chg: move feFopen to findexec dir.
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • Singular/fevoices.cc

    ra10fdf r854405  
    2727#include <omalloc/omalloc.h>
    2828#include <reporter/reporter.h>
    29 #include <resources/feFopen.h>
    3029#include <misc/options.h>
    3130
  • Singular/mpsr_sl.cc

    ra10fdf r854405  
    294294      l->data = (void *) link;
    295295      fe_fgets_stdin=fe_fgets_dummy;
     296      WerrorS_callback=WerrorS_batch;
    296297      singular_in_batchmode=TRUE;
    297298      //myynest=0;
  • Singular/ssiLink.cc

    ra10fdf r854405  
    784784          //myynest=0;
    785785          fe_fgets_stdin=fe_fgets_dummy;
     786          WerrorS_callback=WerrorS_batch;
    786787          if ((u!=NULL)&&(u->rtyp==IDHDL))
    787788          {
  • findexec/Makefile.am

    ra10fdf r854405  
    1616INCLUDES = -I${top_srcdir} -I${top_builddir}
    1717
    18 SOURCES  = omFindExec.c feResource.cc
     18SOURCES  = omFindExec.c feResource.cc feFopen.cc
    1919libfindexec_la_SOURCES   = $(SOURCES)
    2020libfindexec_g_la_SOURCES = $(SOURCES)
     
    2222libfindexec_includedir  =$(includedir)/singular/findexec/
    2323
    24 libfindexec_include_HEADERS = omFindExec.h feResource.h
     24libfindexec_include_HEADERS = omFindExec.h feResource.h feFopen.h
    2525
    2626
  • kernel/febase.cc

    ra10fdf r854405  
    2727#include <omalloc/omalloc.h>
    2828#include <reporter/reporter.h>
    29 #include <resources/feFopen.h>
    3029#include <misc/options.h>
    3130
  • kernel/febase.h

    ra10fdf r854405  
    1010#include <reporter/reporter.h>
    1111
    12 #include <resources/feFopen.h>
    1312#include <findexec/feResource.h>
    1413
  • kernel/feread.cc

    ra10fdf r854405  
    2727#ifdef HAVE_STATIC
    2828#undef HAVE_DYN_RL
    29 #endif
    30 
    31 #ifdef ix86_Linux
    32 #undef HAVE_FEREAD
    33 // not compatible with glibc2
    3429#endif
    3530
  • libpolys/coeffs/ffields.cc

    ra10fdf r854405  
    1515
    1616#include <reporter/reporter.h>
    17 #include <resources/feFopen.h>
    1817
    1918#include <coeffs/coeffs.h>
  • libpolys/coeffs/gnumpc.cc

    ra10fdf r854405  
    1717
    1818#include <reporter/reporter.h>
    19 #include <resources/feFopen.h>
    2019
    2120#include <coeffs/coeffs.h>
  • libpolys/polys/mod_raw.cc

    ra10fdf r854405  
    2525
    2626#include <findexec/feResource.h>
    27 #include <resources/feFopen.h>
    2827
    2928#include "mod_raw.h"
  • libpolys/reporter/reporter.cc

    ra10fdf r854405  
    2222#include <reporter/reporter.h>
    2323#include <findexec/feResource.h>
     24#include <findexec/feFopen.h>
    2425#include <omalloc/omalloc.h>
    2526//#include "options.h"
     
    3738static char * feBuffer=(char *)omAlloc(INITIAL_PRINT_BUFFER);
    3839
    39 BOOLEAN errorreported = FALSE;
    4040char *  feErrors=NULL;
    4141int     feErrorsLen=0;
     
    4343BOOLEAN feOut = TRUE;
    4444
    45 void (*WerrorS_callback)(const char *s) = NULL;
     45//void (*WerrorS_callback)(const char *s) = NULL;
    4646
    4747const char feNotImplemented[]="not implemented";
     
    147147#endif
    148148
    149 extern "C" {
    150 void WerrorS(const char *s)
    151 {
    152 #ifdef HAVE_MPSR
    153   if (fe_fgets_stdin==fe_fgets_dummy)
    154   {
    155     if (feErrors==NULL)
    156     {
    157       feErrors=(char *)omAlloc(256);
    158       feErrorsLen=256;
    159       *feErrors = '\0';
    160     }
    161     else
    162     {
    163       if (((int)(strlen((char *)s)+ 20 +strlen(feErrors)))>=feErrorsLen)
    164       {
    165         feErrors=(char *)omReallocSize(feErrors,feErrorsLen,feErrorsLen+256);
    166         feErrorsLen+=256;
    167       }
    168     }
    169     strcat(feErrors, "Singular error: ");
    170     strcat(feErrors, (char *)s);
     149void WerrorS_batch(const char *s)
     150{
     151  if (feErrors==NULL)
     152  {
     153    feErrors=(char *)omAlloc(256);
     154    feErrorsLen=256;
     155    *feErrors = '\0';
    171156  }
    172157  else
    173 #endif
    174   {
    175 #ifdef HAVE_TCL
    176     if (tclmode)
    177     {
    178       PrintTCLS('E',(char *)s);
    179       PrintTCLS('E',"\n");
    180     }
    181     else
    182 #endif
    183     {
    184       if (WerrorS_callback == NULL)
    185       {
    186         fwrite("   ? ",1,5,stderr);
    187         fwrite((char *)s,1,strlen((char *)s),stderr);
    188         fwrite("\n",1,1,stderr);
    189         fflush(stderr);
    190       }
    191       else
    192       {
    193         WerrorS_callback(s);
    194       }
    195       if (feProt&PROT_O)
    196       {
    197         fwrite("   ? ",1,5,feProtFile);
    198         fwrite((char *)s,1,strlen((char *)s),feProtFile);
    199         fwrite("\n",1,1,feProtFile);
    200       }
    201     }
    202   }
     158  {
     159    if (((int)(strlen((char *)s)+ 20 +strlen(feErrors)))>=feErrorsLen)
     160    {
     161      feErrors=(char *)omReallocSize(feErrors,feErrorsLen,feErrorsLen+256);
     162      feErrorsLen+=256;
     163    }
     164  }
     165  strcat(feErrors, "Singular error: ");
     166  strcat(feErrors, (char *)s);
    203167  errorreported = TRUE;
    204 #ifdef HAVE_FACTORY
    205 #ifdef HAVE_LIBFAC
    206   // libfac:
    207   extern int libfac_interruptflag;
    208   libfac_interruptflag=1;
    209 #endif
    210 #endif
    211168}
    212169
     
    248205  }
    249206}
    250 } /* end extern "C" */
    251207
    252208void Warn(const char *fmt, ...)
  • libpolys/reporter/reporter.h

    ra10fdf r854405  
    1010#include <string.h>
    1111#include <misc/auxiliary.h>
     12#include <findexec/feFopen.h>
    1213
    1314extern char*  feErrors;
     
    1819extern int    yy_noeof;
    1920extern const char feNotImplemented[];
    20 extern BOOLEAN errorreported;
    2121extern int     feProt;
    2222extern BOOLEAN feWarn;
     
    4444
    4545void    Werror(const char *fmt, ...) __attribute__((format(printf,1,2)));
    46 void    WerrorS(const char *s);
     46void    WerrorS_batch(const char *s);
    4747void    WarnS(const char *s);
    4848void    Print(const char* fmt, ...) __attribute__((format(printf,1,2)));
     
    8181{
    8282#endif
    83 extern void (*WerrorS_callback)(const char *s);
    8483extern int dReportError(const char* fmt, ...);
    8584#define dReportBug(s) \
  • libpolys/resources/Makefile.am

    ra10fdf r854405  
    1616INCLUDES = -I${top_srcdir} -I${top_srcdir}/.. -I${top_builddir} -I${top_builddir}/..
    1717
    18 SOURCES = feFopen.cc
     18SOURCES =
    1919libresources_la_SOURCES   = $(SOURCES)
    2020libresources_g_la_SOURCES = $(SOURCES)
     
    2222libresources_includedir  =$(includedir)/singular/resources
    2323
    24 libresources_include_HEADERS   = feFopen.h
     24libresources_include_HEADERS   =
    2525
    2626
  • libpolys/resources/feFopen.cc

    ra10fdf r854405  
    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <sys/types.h>
    5 #include <sys/stat.h>
    6 #include <unistd.h>
    7 
    8 #include "config.h"
    9 #include <misc/auxiliary.h>
    10 
    11 #include <reporter/reporter.h>
    12 
    13 #include "feFopen.h"
    14 #include <findexec/feResource.h>
    15 
    16 
    17 
    18 /*****************************************************************
    19  *
    20  * File handling
    21  *
    22  *****************************************************************/
    23 
    24 FILE * feFopen(const char *path, const char *mode, char *where,
    25                BOOLEAN useWerror, BOOLEAN path_only)
    26 {
    27   char longpath[MAXPATHLEN];
    28   if (path[0]=='~')
    29   {
    30     if (path[1] == DIR_SEP)
    31     {
    32       const char* home = getenv("HOME");
    33 #ifdef ix86_Win
    34       if ((home==NULL)||(!access(home,X_OK)))
    35         home = getenv("SINGHOME");
    36 #endif
    37       if (home != NULL)
    38       {
    39         strcpy(longpath, home);
    40         strcat(longpath, &(path[1]));
    41         path = longpath;
    42       }
    43     }
    44 #if defined(HAVE_PWD_H) && defined(HAVE_GETPWNAM)
    45     else
    46     {
    47       char* dir_sep;
    48       struct passwd *pw_entry;
    49       strcpy (longpath, path);
    50       dir_sep = strchr(longpath, DIR_SEP);
    51       if (dir_sep==NULL)
    52       {
    53         Werror(" illegal ~ in filename >>%s<<",longpath);
    54         return NULL;
    55       }
    56       *dir_sep = '\0';
    57       pw_entry = getpwnam(&longpath[1]);
    58       if (pw_entry != NULL)
    59       {
    60         strcpy(longpath, pw_entry->pw_dir);
    61         dir_sep = strchr((char *)path, DIR_SEP);
    62         strcat(longpath, dir_sep);
    63         path = longpath;
    64       }
    65     }
    66 #endif
    67   }
    68   FILE * f=NULL;
    69   if (! path_only)
    70   {
    71     struct stat statbuf;
    72     if ((stat(path,&statbuf)==0)
    73     && (S_ISREG(statbuf.st_mode)))
    74       f = myfopen(path,mode);
    75   }
    76   if (where!=NULL) strcpy(where,path);
    77   if ((*mode=='r') &&
    78       (path[0]!=DIR_SEP) &&
    79       ! (path[0] == '.' && path[1] == DIR_SEP) &&
    80       (f==NULL))
    81   {
    82     char found = 0;
    83     char* spath = feResource('s');
    84     char *s;
    85 
    86     if (where==NULL) s=(char *)malloc(1024);
    87     else             s=where;
    88 
    89     if (spath!=NULL)
    90     {
    91       char *p,*q;
    92       p = spath;
    93       while( (q=strchr(p, fePathSep)) != NULL)
    94       {
    95         *q = '\0';
    96         strcpy(s,p);
    97         *q = fePathSep;
    98         strcat(s, DIR_SEPP);
    99         strcat(s, path);
    100         if(!access(s, R_OK)) { found++; break; }
    101         p = q+1;
    102       }
    103       if(!found)
    104       {
    105         strcpy(s,p);
    106         strcat(s, DIR_SEPP);
    107         strcat(s, path);
    108       }
    109       f=myfopen(s,mode);
    110       if (f!=NULL)
    111       {
    112         if (where==NULL) free((ADDRESS)s);
    113         return f;
    114       }
    115     }
    116     else
    117     {
    118       if (where!=NULL) strcpy(s/*where*/,path);
    119       f=myfopen(path,mode);
    120     }
    121     if (where==NULL) free((ADDRESS)s);
    122   }
    123   if ((f==NULL)&&(useWerror))
    124     Werror("cannot open `%s`",path);
    125   return f;
    126 }
    127 
    128 FILE * feFopen(const char *path, const char *mode)
    129 {
    130   return feFopen (path, mode, 0,0,0);
    131 }
    132 
    133 // Make sure that mode contains binary option
    134 FILE* myfopen(const char *path, const char *mode)
    135 {
    136 #if (defined(CYGWIN) || defined(ix86_Win))
    137   char mmode[4];
    138   int i;
    139   int done = 0;
    140 
    141   for (i=0;;i++)
    142   {
    143     mmode[i] = mode[i];
    144     if (mode[i] == '\0') break;
    145     if (mode[i] == 'w') done = 1;
    146     if (mode[i] == 'a') done = 1;
    147     if (mode[i] == 'b') done = 1;
    148   }
    149 
    150   if (! done)
    151   {
    152     mmode[i] = 'b';
    153     mmode[i+1] = '\0';
    154   }
    155   return fopen(path, mmode);
    156 #else
    157   return fopen(path, mode);
    158 #endif
    159 }
    160 // replace "\r\n" by " \n" and "\r" by "\n"
    161 
    162 size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
    163 {
    164   size_t got = fread(ptr, size, nmemb, stream) * size;
    165   size_t i;
    166 
    167   for (i=0; i<got; i++)
    168   {
    169     if ( ((char*) ptr)[i] == '\r')
    170     {
    171       if (i+1 < got && ((char*) ptr)[i+1] == '\n')
    172         ((char*) ptr)[i] = ' ';
    173       else
    174         ((char*) ptr)[i] = '\n';
    175     }
    176   }
    177   return got;
    178 }
Note: See TracChangeset for help on using the changeset viewer.