jos@cs.vu.nl (Jos Warmer) (03/16/90)
Jean-Pierre Sarkis writes: =================================================================== The garbage collector problem encountered by Paul Menon and Jos Warmer apparently corresponds to a bug in the run-time system of 2.2B, which manifests itself when the garbage collector is run in certain conditions (having to do with string objects). The following fix, which should remove Professor Menon's problem, may be applied by all installations. The correction should be applied to routine get_arg in file _basic.c in directory INSTALLATION_DIRECTORY/Eiffel/files. ... 3. Edit this file and change the definition of function get_arg () as indicated below in ``diff'' format. ................. BEGIN CHANGE ...................... 220,221c220,221 < DATUM strarg; < if(n >= argc) return(DATINT(0)); --- > DATPTR strarg; > if(n >= argc) return((DATUM)NULL); 238,240c238,241 < strarg = DATOBJ ( MakeStr(p+1)); < if (gac_option) ONCE(strarg); < return(strarg); --- > strarg = (DATPTR)malloc (sizeof(DATPTR)); > (*strarg) = DATOBJ ( MakeStr(p+1)); > if (gac_option) ONCE(*strarg); > return(*strarg); 260,262c261,264 < strarg = DATOBJ ( MakeStr(p)); < if (gac_option) ONCE(strarg); < return(strarg); --- > strarg = (DATPTR)malloc (sizeof(DATPTR)); > (*strarg) = DATOBJ ( MakeStr(p)); > if (gac_option) ONCE(*strarg); > return(*strarg); ................. END CHANGE ...................... ====================================================================== This morning I received version 2.2B and I tried to fix this. I looked into the file _basic.c and the code for the function get_arg() does not look at all like the code mentioned above. Maybe Jean-Pierre has a different version in mind ? My version of the function is shown below, for reference. Could someone please send the fix for 2.2B, it is needed very much. Jos Warmer jos@cs.vu.nl (version 2.2 level B, SUN4/O.S.4.0, site licence) ========================= get_arg() ================================== DATUM get_arg(n,argc,argv) int n; int argc; char *argv[]; { char *p; int i; short discr; if(n >= argc) return(DATINT(0)); /* COMMENT JOS: line 220 */ p = malloc (strlen (argv [n]) + 1); strcpy (p, argv [n]); if(*p == '\'') { if(p[2] == '\'') return(DATCHAR (p[1])); else if(p[1] == '\\') switch (p[2]) { case 'n':return(DATCHAR ( '\n')); case 't':return(DATCHAR ( '\t')); case 'b':return(DATCHAR ( '\b')); case 'd':return(DATCHAR ( '\d')); default :return(DATINT(0)); } } else if(p[0] == '\"' && p[strlen(p) - 1] == '\"') { p[strlen(p) - 1] = '\0'; return(DATOBJ ( MakeStr(p+1))); } else { str_lower (p); if(!strcmp(p,"true")) return(DATBOOL (TRUE)); else if(!strcmp(p,"false")) return(DATBOOL (FALSE)); else { strcpy (p, argv [n]); discr = 0; for (i=0; discr==0; i++) { if (p[i] == '\0' && i>0) discr = 2; else if (p[i] < '0' || p[i] > '9') discr = 1; } if (discr == 2) return (DATINT (atoi (p))); else return (DATOBJ ( MakeStr (p))); } } } -- Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos