Changeset d5f35ac in git


Ignore:
Timestamp:
Apr 27, 1998, 2:34:22 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
52d073b058c2293d5f5aaa2eea8ff1478ba294b8
Parents:
2e5cd04618ebbbd75f9a6282e19d900d77239f80
Message:
1998-04-27  Olaf Bachmann  <obachman@mathematik.uni-kl.de>

	* febase.cc (myfread): introduced myfread and myfopen which assure
	that newlines in text files are always \n


git-svn-id: file:///usr/local/Singular/svn/trunk@1483 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • Singular/ChangeLog

    r2e5cd0 rd5f35ac  
     11998-04-27  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
     2
     3        * febase.cc (myfread): introduced myfread and myfopen which assure
     4        that newlines in text files are always \n
     5
    16Fri Apr 24 19:14:42 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
    27
     
    6772 * fixed a minor but very nasty bug: nlSetMap was resetting npPrimeM
    6873    (longrat.cc)
     74
     751998-04-21  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
     76
     77        * mmprivat.h: Got rid off mmheap.cc, "inlined" mmPutMemory
     78
     79        * longalg.h:  Exponents in parameter (polys) are typedef'ed to
     80        EXPONENT_TYPE
     81
     821998-04-20  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
     83
     84        * mmallocb.c: Merged with mmheap.c.
    6985
    70861998-04-16  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
  • Singular/extra.cc

    r2e5cd0 rd5f35ac  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.40 1998-04-24 17:19:04 schmidt Exp $ */
     4/* $Id: extra.cc,v 1.41 1998-04-27 12:34:11 obachman Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    280280      {
    281281        res->data = (void*) val;
    282         if ((int) val > 1)
     282        if ((unsigned int) val > 1)
    283283        {
    284284          res->rtyp=STRING_CMD;
     
    437437    else
    438438#endif
    439 /*==================== writemat ==================================*/
    440 //    if(strcmp((char*)(h->Data()),"writemat")==0)
    441 //    {
    442 //      if (h->next!=NULL)
    443 //      {
    444 //        leftv v=h->next;
    445 //        if (v->Typ() == STRING_CMD)
    446 //        {
    447 //          char *filename = (char *)v->Data();
    448 //          v = v->next;
    449 //          if (v->Typ()==MATRIX_CMD)
    450 //          {
    451 //            FILE *outfile = fopen(filename,"a");
    452 //            if (outfile==NULL)
    453 //            {
    454 //              Werror("cannot write to file %s",filename);
    455 //              return TRUE;
    456 //            }
    457 //            matrix m=(matrix)v->Data();
    458 //            fprintf(outfile,"%d\n%d\n",MATROWS(m),MATCOLS(m));
    459 //            char *s = iiStringMatrix(m,2);
    460 //            fprintf(outfile,"%s\n",s);
    461 //            FreeL((ADDRESS)s);
    462 //            fclose(outfile);
    463 //            return FALSE;
    464 //          }
    465 //          else
    466 //          {
    467 //            WerrorS("matrix expected");
    468 //          }
    469 //        }
    470 //        else
    471 //        {
    472 //          WerrorS("string expected");
    473 //        }
    474 //      }
    475 //      else
    476 //        WerrorS("matrix expected");
    477 //    }
    478 //    else
    479439#ifdef HAVE_FACTORY
    480440/*==================== pdivide ====================*/
  • Singular/febase.cc

    r2e5cd0 rd5f35ac  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: febase.cc,v 1.31 1998-04-23 18:52:48 Singular Exp $ */
     4/* $Id: febase.cc,v 1.32 1998-04-27 12:34:12 obachman Exp $ */
    55/*
    66* ABSTRACT: i/o system
     
    2323#include "subexpr.h"
    2424#include "ipshell.h"
     25
    2526
    2627#define fePutChar(c) fputc((uchar)(c),stdout)
     
    211212FILE * feFopen(char *path, char *mode, char *where,int useWerror)
    212213{
    213   FILE * f=fopen(path,mode);
     214  FILE * f=myfopen(path,mode);
    214215#ifdef macintosh
    215216  if (f!=NULL)
     
    240241    memcpy(res+ienv,path,ipath);
    241242    res[ienv+ipath]='\0';
    242     f=fopen(res,mode);
     243    f=myfopen(res,mode);
    243244  }
    244245  if ((f==NULL)&&(idat!=0))
     
    247248    memcpy(res+idat,path,ipath);
    248249    res[idat+ipath]='\0';
    249     f=fopen(res,mode);
     250    f=myfopen(res,mode);
    250251  }
    251252  if (f==NULL)
     
    283284          if(!access(s, R_OK)) { found++; break; }
    284285        #else
    285           f=fopen(s,mode);
     286          f=myfopen(s,mode);
    286287          if (f!=NULL)  { found++; fclose(f); break; }
    287288        #endif
     
    294295        strcat(s, path);
    295296      }
    296       f=fopen(s,mode);
     297      f=myfopen(s,mode);
    297298      if (f!=NULL)
    298299      {
     
    304305    {
    305306      if (where!=NULL) strcpy(s/*where*/,path);
    306       f=fopen(path,mode);
     307      f=myfopen(path,mode);
    307308    }
    308309    if (where==NULL) FreeL((ADDRESS)s);
     
    631632  if ((s!=NULL) && (*s!='\0'))
    632633  {
    633     feProtFile = fopen(s,"w");
     634    feProtFile = myfopen(s,"w");
    634635    if (feProtFile==NULL)
    635636    {
     
    667668}
    668669
     670#ifndef unix
     671// Make sure that mode contains binary option
     672FILE *myfopen(char *path, char *mode)
     673{
     674  char mmode[4];
     675  int i;
     676  BOOLEAN done = FALSE;
     677 
     678  for (i=0;;i++)
     679  {
     680    mmode[i] = mode[i];
     681    if (mode[i] == '\0') break;
     682    if (mode[i] == 'b') done = TRUE;
     683  }
     684 
     685  if (! done)
     686  {
     687    mmode[i] = 'b';
     688    mmode[i+1] = '\0';
     689  }
     690  return fopen(path, mmode);
     691}
     692#endif
     693
     694// replace "\r\n" by " \n" and "\r" by "\n"
     695
     696size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
     697{
     698  size_t got = fread(ptr, size, nmemb, stream) * size;
     699  size_t i;
     700
     701  for (i=0; i<got; i++)
     702  {
     703    if ( ((char*) ptr)[i] == '\r')
     704    {
     705      if (i+1 < got && ((char*) ptr)[i+1] == '\n')
     706        ((char*) ptr)[i] = ' ';
     707      else
     708        ((char*) ptr)[i] = '\n';
     709    }
     710  }
     711  return got;
     712}
     713
     714
     715     
  • Singular/febase.h

    r2e5cd0 rd5f35ac  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: febase.h,v 1.14 1998-04-23 18:52:49 Singular Exp $ */
     6/* $Id: febase.h,v 1.15 1998-04-27 12:34:13 obachman Exp $ */
    77/*
    88* ABSTRACT
     
    1111#include <string.h>
    1212#include "structs.h"
     13
     14
     15// These are our versions of fopen and fread They are very similar to
     16// the usual fopen and fread, except that on reading, they always
     17// convert "\r\n" into " \n" and "\r" into "\n".
     18//
     19// IMPORTANT: do only use myfopen and myfread when reading text,
     20// do never use fopen and fread
     21#ifndef unix
     22extern FILE *myfopen(char *path, char *mode);
     23#else
     24#define myfopen fopen
     25#endif
     26extern size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream);
    1327
    1428extern char*  feErrors;
  • Singular/feread.cc

    r2e5cd0 rd5f35ac  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: feread.cc,v 1.9 1998-03-31 09:00:40 Singular Exp $ */
     4/* $Id: feread.cc,v 1.10 1998-04-27 12:34:14 obachman Exp $ */
    55/*
    66* ABSTRACT: input from ttys, simulating fgets
     
    226226      fe_stdout_is_tty=0;
    227227      #ifdef atarist
    228         fe_echo = fopen( "/dev/tty", "w" );
    229       #else
    230         fe_echo = fopen( ttyname(fileno(stdin)), "w" );
     228        fe_echo = myfopen( "/dev/tty", "w" );
     229      #else
     230        fe_echo = myfopen( ttyname(fileno(stdin)), "w" );
    231231      #endif
    232232    }
     
    661661    {
    662662      #ifdef atarist
    663         rl_outstream = fopen( "/dev/tty", "w" );
    664       #else
    665         rl_outstream = fopen( ttyname(fileno(stdin)), "w" );
     663        rl_outstream = myfopen( "/dev/tty", "w" );
     664      #else
     665        rl_outstream = myfopen( ttyname(fileno(stdin)), "w" );
    666666      #endif
    667667    }
  • Singular/iparith.cc

    r2e5cd0 rd5f35ac  
    42904290void ttGen1()
    42914291{
    4292   FILE *outfile = fopen("iparith.inc","w");
     4292  FILE *outfile = myfopen("iparith.inc","w");
    42934293  int i,j,l1=0,l2=0;
    42944294  currRing=(ring)Alloc(sizeof(*currRing));
     
    44484448void ttGen2()
    44494449{
    4450   FILE *outfile = fopen("iparith.inc","a");
     4450  FILE *outfile = myfopen("iparith.inc","a");
    44514451  fprintf(outfile,
    44524452  "/****************************************\n"
     
    45764576void ttGen3()
    45774577{
    4578   FILE *outfile = fopen("mpsr_tok.inc","w");
     4578  FILE *outfile = myfopen("mpsr_tok.inc","w");
    45794579  fprintf(outfile,
    45804580  "/****************************************\n"
  • Singular/iplib.cc

    r2e5cd0 rd5f35ac  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: iplib.cc,v 1.19 1998-04-22 10:37:44 krueger Exp $ */
     4/* $Id: iplib.cc,v 1.20 1998-04-27 12:34:16 obachman Exp $ */
    55/*
    66* ABSTRACT: interpreter: LIB and help
     
    144144    //    pi->data.s.proc_start, procbuflen);
    145145    s = (char *)AllocL(procbuflen);
    146     fread(s, procbuflen, 1, fp);
     146    myfread(s, procbuflen, 1, fp);
    147147    s[procbuflen] = '\0';
    148148    return(s);
     
    152152    procbuflen = pi->data.s.def_end - pi->data.s.proc_start;
    153153    //fgets(buf, sizeof(buf), fp);
    154     fread( buf, procbuflen, 1, fp);
     154    myfread( buf, procbuflen, 1, fp);
    155155    char ct;
    156156    char *e;
     
    171171    fseek(fp, pi->data.s.body_start, SEEK_SET);
    172172    strcpy(pi->data.s.body,argstr);
    173     fread( pi->data.s.body+strlen(argstr), procbuflen, 1, fp);
     173    myfread( pi->data.s.body+strlen(argstr), procbuflen, 1, fp);
    174174    procbuflen+=strlen(argstr);
    175175    FreeL(argstr);
     
    190190    //  pi->data.s.example_start, procbuflen);
    191191    s = (char *)AllocL(procbuflen+14);
    192     fread(s, procbuflen, 1, fp);
     192    myfread(s, procbuflen, 1, fp);
    193193    s[procbuflen] = '\0';
    194194    strcat(s+procbuflen-3, "\n;return();\n\n" );
  • Singular/libparse.l

    r2e5cd0 rd5f35ac  
    33*  Computer Algebra System SINGULAR     *
    44****************************************/
    5 /* $Id: libparse.l,v 1.11 1998-04-27 10:55:55 Singular Exp $ */
     5/* $Id: libparse.l,v 1.12 1998-04-27 12:34:18 obachman Exp $ */
    66#include <stdio.h>
    77#include <string.h>
     
    571571
    572572  offset = ftell(f);
    573   rc  = fread( buf, 1, max_size, f );
     573  rc  = myfread( buf, 1, max_size, f );
    574574#if YYLPDEBUG >2
    575575  printf("fread: %d of %d\n", rc, max_size);
     
    634634    text_buffer = (char *)AllocL(len+1);
    635635    text_buffer[len]='\0';
    636     fread(text_buffer, len, 1, yylpin);
     636    myfread(text_buffer, len, 1, yylpin);
    637637    fseek(yylpin, current_location, SEEK_SET);
    638638  }
     
    663663  ++argv, --argc;  /* skip over program name */
    664664  if ( argc > 0 )
    665      yyin = fopen( argv[0], "rb" );
     665     yyin = myfopen( argv[0], "rb" );
    666666  else
    667667     yyin = stdin;
  • Singular/mpsr_Tok.cc

    r2e5cd0 rd5f35ac  
    33****************************************/
    44
    5 /* $Id: mpsr_Tok.cc,v 1.11 1998-04-01 18:56:30 Singular Exp $ */
     5/* $Id: mpsr_Tok.cc,v 1.12 1998-04-27 12:34:19 obachman Exp $ */
    66
    77/***************************************************************
     
    514514
    515515  // Generate the template file
    516   outfile = fopen("mpsr_Tok.inc", "w");
     516  outfile = myfopen("mpsr_Tok.inc", "w");
    517517  if (outfile == NULL)
    518518  {
     
    582582  system("touch mpsr_Tok.inc");
    583583#else
    584   FILE fd = fopen("mpsr_Tok.inc", "w");
     584  FILE fd = myfopen("mpsr_Tok.inc", "w");
    585585  close(fd);
    586586#endif
  • Singular/silink.cc

    r2e5cd0 rd5f35ac  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: silink.cc,v 1.16 1998-04-07 18:35:27 obachman Exp $ */
     4/* $Id: silink.cc,v 1.17 1998-04-27 12:34:21 obachman Exp $ */
    55
    66/*
     
    394394    if (BVERBOSE(V_READING))
    395395      Print("//Reading %d chars\n",len);
    396     fread( buf, len, 1, fp);
     396    myfread( buf, len, 1, fp);
    397397    buf[len]='\0';
    398398  }
  • Singular/utils.cc

    r2e5cd0 rd5f35ac  
    4444printpi(procinfov pi)
    4545{
    46   FILE *fp = fopen( pi->libname, "rb");
     46  FILE *fp = mfopen( pi->libname, "rb");
    4747  char *buf, name[256];
    4848  int len1, len2;
     
    6767    buf = (char *)malloc(len1 + len2 + 1);
    6868    fseek(fp, pi->data.s.proc_start, SEEK_SET);
    69     fread( buf, len1, 1, fp);
     69    mfread( buf, len1, 1, fp);
    7070    *(buf+len1) = '\n';
    7171    fseek(fp, pi->data.s.body_start, SEEK_SET);
    72     fread( buf+len1+1, len2, 1, fp);
     72    mfread( buf+len1+1, len2, 1, fp);
    7373    *(buf+len1+len2+1)='\0';
    7474    printf("##BODY:'%s'##\n", buf);
     
    8080    buf = (char *)malloc(len1+1);
    8181    fseek(fp, pi->data.s.proc_start, SEEK_SET);
    82     fread( buf, len1, 1, fp);
     82    mfread( buf, len1, 1, fp);
    8383    *(buf+len1)='\0';
    8484    printf("##HELP:'%s'##\n", buf);
Note: See TracChangeset for help on using the changeset viewer.