From: C. Jefferson Blaine (jblaine@garnet.acns.fsu.edu)
Date: 03/27/93


From: jblaine@garnet.acns.fsu.edu (C. Jefferson Blaine)
Subject: gcc, pl6, ext2fs, and my C code
Date: 28 Mar 1993 00:21:10 GMT

With SLS linux 0.99pl6, gcc 2.3.3, and a main 71meg linux extended
partition, the following code goes into an infinite loop, spewing
my printf debugging messages to the screen with values of "0" and ";"
instead of actual english like strings and then ending.
This code works fine with AIX 3.2 and other OSs that I have it compiled
on. It is a simple loop that opens a file associated with the filename
passed to the function (which is being passed correctly), and reads
in lines of the file into a multi-level linked list and then returns.
the file to be loaded has the form:
OBJ:
object1
attribute1 value1
attribute2 value2
....
OBJ:
object2
attribute1 value1
attribute2 value2
...

/* LOADDB */
int loaddb (char *fname)
{
FILE *fp;
char temp[80], temp2[80];
char object[30];

if (strlen(fname) == 0) {
        printf("error: No filename provided.\n");
        return(0);
}
fname[strlen(fname)-1]='\0';
printf("In loaddb. fname is %s\n", fname);
if ((fp = fopen(fname, "r")) == NULL) {
        printf("error: file \"%s\" not found.\n", fname);
        fclose(fp);
        return(0);
}
while (!feof(fp)) {
        fgets (temp, 80, fp);
        printf ("Line gotten: %s\n", temp);
        if (!strcmp (temp, "OBJ:\n")) {
                fgets (object, 30, fp);
                printf("Adding object: %s\n", object);
                addobj (object);
        } else {
                fgets (temp, 80, fp);
                strcpy (temp2, object);
                strcat (temp2, " ");
                strcat (temp2, temp);
                printf ("Calling addatt with: %s\n", temp2);
                addatt (temp2);
        }
}
fclose(fp);
return(1);
}

-- 
=======
C. Jefferson Blaine
jblaine@garnet.acns.fsu.edu