avadekar@sunee.waterloo.edu (Ashok Vadekar) (06/07/91)
I think I have found a bug in Lattice's (5.10a) implementation of sscanf (probably in scanf and fscanf as well). The %*s formatting sequence seems to generate enforcer hits: specifically a long read from address 0 followed by a byte write to adress 0. Could people with an '030 machine (ie with an MMU) test the following two programs and reply to the net? main() { char string1[50],string2[50]; sscanf(" first_string second_string third_string ","%*s %s %s", string1,string2); } main() { char string1[50],string2[50]; sscanf(" first_string second_string third_string ","%s %s %s", string1,string1,string2); } The second should run correctly, the first shold too, but seems to generate the enforcer hits mentioned. Ashok Vadekar
tll@nntp-server.caltech.edu (Tal Lewis Lancaster) (06/08/91)
avadekar@sunee.waterloo.edu (Ashok Vadekar) writes: >I think I have found a bug in Lattice's (5.10a) implementation of sscanf >(probably in scanf and fscanf as well). The %*s formatting sequence seems >to generate enforcer hits: specifically a long read from address 0 followed >by a byte write to adress 0. Could people with an '030 machine (ie with >an MMU) test the following two programs and reply to the net? Yes, this is true, for all of the scanf, related functions. They all cause Enforcer hits when using the assignment suppression character '*'. SAS has been aware of the problem for a long time. As far as I can tell there is no real harm done. It is just a real annoying. Especially, when you are reading 25 parameters at a time and ignoring all but three of them. Some more information that might save you sime grief. If you do use the suppression character the result (assuming all went as expected) will be all of the parameters and NOT the number that was assigned. Example result = fscanf (foo, "%s %*d %d", str1, &num1); Asumming there were at least three things to read the result will be 3 rather than 2. Also SAS's scanf functions ignore the [...] argument so don't bother using it. and related functions) >main() { >char string1[50],string2[50]; >sscanf(" first_string second_string third_string ","%*s %s %s", >string1,string2); >} Here is >main() { >char string1[50],string2[50]; >sscanf(" first_string second_string third_string ","%s %s %s", >string1,string1,string2); >} >The second should run correctly, the first shold too, but seems to generate >the enforcer hits mentioned. Here is an example of how I am working around the problem: main () { ... code and stuff #ifndef __SAS_510 /* Sorry off this is off top of my head so this symbol may not be right. Check SAS's README. */ if (fscanf (foo, "%*d %*s %s", mystring) == 1) /* ok so do something */ #else { int tempint; char tempstr[255]; if (fscanf (foo, "%d %s %s", &tempint, tempstr, mystring) == 3) /* ok so do something */ } #endif ... more code and stuff } >Ashok Vadekar Tal Lancaster