Changeset e038d4a in git


Ignore:
Timestamp:
Jul 5, 2002, 8:51:34 AM (22 years ago)
Author:
Anne Frühbis-Krüger <anne@…>
Branches:
(u'spielwiese', 'd1d239e9808fca76a9497a01fa91ad4e8db6fba5')
Children:
8738324a8dbbecfcc0e8d3ab852389a3a861cd73
Parents:
129adc590104e54820a978cab9aa4febf064f4b3
Message:
*anne: added some sanity checks for opening the .bin file


git-svn-id: file:///usr/local/Singular/svn/trunk@6193 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
modules/modgen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • modules/modgen/creat_top.cc

    r129adc5 re038d4a  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: creat_top.cc,v 1.18 2002-07-04 14:18:36 anne Exp $ */
     4/* $Id: creat_top.cc,v 1.19 2002-07-05 06:51:33 anne Exp $ */
    55/*
    66* ABSTRACT: lib parsing
     
    132132  fprintf(fp, "  memcpy(tempstr+strlen(currPack->libname)-3,\".bin\",4);\n");
    133133  fprintf(fp, "  ret=stat(tempstr,&sb);\n");
    134   fprintf(fp, "  if((ret==0) && ((sb.st_mode & S_IFMT) == S_IFREG)) { \n");
    135   fprintf(fp, "    if (crccheck(tempstr)!=crcsum) ret=-1;\n");
    136   fprintf(fp, "    if ((binfp = fopen(tempstr,\"r\")) == NULL) return -1;\n");
    137   fprintf(fp, "  } \n  else { \n    ret=-1; \n  }\n\n");
     134  fprintf(fp, "  if(ret==0) { \n");
     135  fprintf(fp, "    if ((sb.st_mode & S_IFMT) == S_IFREG) { \n");
     136  fprintf(fp, "      if (crccheck(tempstr)!=crcsum) ret=-1;\n");
     137  fprintf(fp, "      if ((binfp = fopen(tempstr,\"r\")) == NULL) return -1;\n");
     138  fprintf(fp, "    } \n    else \n      ret=-1; \n  }\n\n");
    138139  fprintf(fp, "  fill_help_package();\n");
    139140  fprintf(fp, "  fill_example_package();\n\n");
  • modules/modgen/main.cc

    r129adc5 re038d4a  
    169169  }
    170170  if(module_def.binfp   != NULL) {
     171    //we have been writing to it previously
    171172    fclose(module_def.binfp);
    172173    cksm = crccheck(build_filename(&module_def,module_def.targetname,3));
     174  } else {
     175    //we have not been writing to it or we could not open it
     176    if((module_def.binfp=fopen(
     177             build_filename(&module_def,module_def.targetname,3),"w"))!=NULL) {
     178      fprintf(module_def.binfp,"// no Singular procedure for this module\n");
     179      fclose(module_def.binfp);
     180      cksm = crccheck(build_filename(&module_def,module_def.targetname,3));
     181    } else {
     182      printf("Cannot open .bin file!!\n");
     183    }
    173184  }
    174185  if(module_def.modfp_h != NULL) {
  • modules/modgen/proc.cc

    r129adc5 re038d4a  
    11/*
    2  * $Id: proc.cc,v 1.21 2002-07-04 14:18:37 anne Exp $
     2 * $Id: proc.cc,v 1.22 2002-07-05 06:51:34 anne Exp $
    33 */
    44
     
    360360)
    361361{
    362   fprintf(module->modfp, "  fclose(binfp);\n");
     362  fprintf(module->modfp, "  if(ret!=-1) fclose(binfp);\n");
    363363  fprintf(module->modfp, "  return 0;\n}\n\n");
    364364  fflush(module->modfp);
Note: See TracChangeset for help on using the changeset viewer.