[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/lib/classdefs classdata.c gcdparser.h...
From: |
Neil Tiffin |
Subject: |
gnue/geas/lib/classdefs classdata.c gcdparser.h... |
Date: |
Mon, 04 Jun 2001 06:50:11 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/06/04 06:50:11
Modified files:
geas/lib/classdefs: classdata.c gcdparser.h lparser.l
Log message:
Fix Bug: flex code did not properely handle pushing files on stack.
Added protection against long filenames. Minor message changes in debug code.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.c.diff?cvsroot=OldCVS&tr1=1.56&tr2=1.57&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/gcdparser.h.diff?cvsroot=OldCVS&tr1=1.25&tr2=1.26&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/lparser.l.diff?cvsroot=OldCVS&tr1=1.22&tr2=1.23&r1=text&r2=text
Patches:
Index: gnue/geas/lib/classdefs/classdata.c
diff -u gnue/geas/lib/classdefs/classdata.c:1.56
gnue/geas/lib/classdefs/classdata.c:1.57
--- gnue/geas/lib/classdefs/classdata.c:1.56 Tue May 29 12:46:40 2001
+++ gnue/geas/lib/classdefs/classdata.c Mon Jun 4 06:50:11 2001
@@ -22,7 +22,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: classdata.c,v 1.56 2001/05/29 19:46:40 baumannd Exp $
+ $Id: classdata.c,v 1.57 2001/06/04 13:50:11 ntiffin Exp $
*/
@@ -2260,6 +2260,9 @@
yycurrent_container = odl_tree_get_root (newtree);
g_assert (yycurrent_container != NULL);
l = (GList *) files;
+#ifdef DEBUG
+ printf ("\n");
+#endif
while (l)
{
#ifdef DEBUG
@@ -2301,6 +2304,9 @@
expecting_fieldprop = 0;
expect_triggertype = 0;
l = (GList *) files;
+#ifdef DEBUG
+ printf ("\n");
+#endif
while (l)
{
#ifdef DEBUG
@@ -2343,7 +2349,7 @@
if (yyerrorcount > max_errors)
{
yymessage ("Too many errors in post processing. File load failed.");
- return (NULL);
+ /* return (NULL); */
}
odl_link_all_to_tree ((odl_base *) newtree->root, newtree); /* TODO
sloppy, one final time for new entries */
Index: gnue/geas/lib/classdefs/gcdparser.h
diff -u gnue/geas/lib/classdefs/gcdparser.h:1.25
gnue/geas/lib/classdefs/gcdparser.h:1.26
--- gnue/geas/lib/classdefs/gcdparser.h:1.25 Sun May 27 16:00:26 2001
+++ gnue/geas/lib/classdefs/gcdparser.h Mon Jun 4 06:50:11 2001
@@ -21,7 +21,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: gcdparser.h,v 1.25 2001/05/27 23:00:26 ntiffin Exp $
+ $Id: gcdparser.h,v 1.26 2001/06/04 13:50:11 ntiffin Exp $
*/
@@ -67,13 +67,14 @@
/* in structure as the code make heavy
*/
/* use of casts that rely on this being
*/
/* first item in structure.
*/
- /* generic data */
+ /* generic data
*/
GList *contents; /* list of (struct _odl_base *)
*/
- /* business class data */
- gboolean istype; /* true if 'type' keyword was used */
+ /* business class data
*/
+ gboolean istype; /* true if 'type' keyword was used
*/
char *orderby;
- GList *parents; /* list of (char *) */
- GList *indexes; /* list of (struct _odl_index *) */
+ GList *parents; /* list of (char *)
*/
+ GList *indexes; /* list of (struct _odl_index *)
*/
+ char *filename; /* filename that defined this container
*/
};
/** \struct _odl_item
Index: gnue/geas/lib/classdefs/lparser.l
diff -u gnue/geas/lib/classdefs/lparser.l:1.22
gnue/geas/lib/classdefs/lparser.l:1.23
--- gnue/geas/lib/classdefs/lparser.l:1.22 Sat May 26 08:47:06 2001
+++ gnue/geas/lib/classdefs/lparser.l Mon Jun 4 06:50:11 2001
@@ -24,7 +24,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: lparser.l,v 1.22 2001/05/26 15:47:06 ntiffin Exp $
+ $Id: lparser.l,v 1.23 2001/06/04 13:50:11 ntiffin Exp $
*/
@@ -61,13 +61,14 @@
#define ST lastyyleng=yyleng
/* tracing position in file(s) */
+#define FILEDATA_FILENAME_LENGTH 512
struct FileData
{
/* stack link */
struct FileData *next;
/* file line info */
- char name[512];
+ char name[FILEDATA_FILENAME_LENGTH];
unsigned long int line;
/* current module info */
@@ -78,18 +79,28 @@
YY_BUFFER_STATE yybuffer;
int dummy[4096];
+ /* int dummy[YY_BUF_SIZE]; */
};
+ /* current file being processed */
struct FileData currentfile = { NULL , "(reading from stdin)" , 1 , "" , "" ,
0 };
-static struct FileData *file_stack = NULL;
+ /* pointer to most recent file pushed */
+static struct FileData *file_stack = NULL;
static int push_file( char *filename );
static int pop_file(); /* return 0 if nothing to pop else return 1 */
static char **processed_files = NULL;
static unsigned int processed_count = 0;
+
static int file_processed( const char *filename );
static int record_file_processed( const char *filename );
+
+#ifdef DEBUG
+static void dump_filedata_struct(struct FileData * filedata_ptr);
+static void dump_file_stack(char * note);
+#endif
+
typedef char *charptr;
%}
@@ -134,15 +145,22 @@
p = yytext + 1;
q = strchr( p , '"' );
*q = '\0';
- /* printf("lparser found file include: %s\n", p); */
+ #ifdef DEBUG
+ printf(" Found include: %s,", p);
+ #endif
if( file_processed(p) )
{
+ #ifdef DEBUG
+ printf(" ALREADY processed.\n");
+ #endif
BEGIN(endincl);
}
else
{
/* not already processed, so start it now */
- /* printf("lparser processing file include: %s\n",
p); */
+ #ifdef DEBUG
+ printf(" processing now.\n");
+ #endif
record_file_processed(p);
if( push_file(p) )
{
@@ -451,9 +469,45 @@
strcpy (currentfile.name, filename);
}
+#ifdef DEBUG
/* ------------------------------------------------------------------------- *\
*
\* ------------------------------------------------------------------------- */
+static void
+dump_file_stack(char * note)
+{
+ struct FileData * tmp = NULL;
+
+ printf("\n**** Dump File Stack: %s *****\n", note);
+ dump_filedata_struct(¤tfile);
+ tmp = file_stack;
+ while (tmp != NULL)
+ {
+ printf("\n FileData: %p\n", tmp);
+ dump_filedata_struct(tmp);
+ tmp = tmp->next;
+ }
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+static void
+dump_filedata_struct(struct FileData * filedata_ptr)
+{
+ printf(" next: %p\n", filedata_ptr->next);
+ printf(" name: %s\n", filedata_ptr->name);
+ printf(" line: %lu\n", filedata_ptr->line);
+ printf(" module name: %s\n", filedata_ptr->modulename);
+ printf(" module prefix: %s\n", filedata_ptr->moduleprefix);
+ printf(" yybuffer: %p\n", filedata_ptr->yybuffer);
+ printf(" dummy: %s\n", filedata_ptr->dummy);
+}
+#endif
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
static int
push_file (char *fn)
{
@@ -462,8 +516,9 @@
char *filename;
char *p;
/*
- printf ("push_file() fn: %s\n", fn);
+ printf ("\npush_file(%s)\n", fn);
printf ("push_file() current.name: %s\n", currentfile.name);
+ dump_file_stack("Before Push");
*/
filename = g_strdup (currentfile.name);
p = &filename[strlen (filename) - 1];
@@ -477,8 +532,9 @@
}
p--;
}
- /* printf ("push_file() p: %s\n", p); */
-
+ /*
+ printf ("push_file() (after strip filename) filename: %s\n", filename);
+ */
/* if necessary add new path/file to old path */
/* include file name is relative to current file location */
if (strcmp (filename, "(reading from stdin)") == 0)
@@ -505,26 +561,33 @@
return (0);
}
/* printf( "fopen : %08lx\n" , newfile ); */
- /* printf ("push_file() filename: %s\n", filename); */
-
+ /*
+ printf ("push_file() open filename: %s\n", filename);
+ */
tmp = (struct FileData *) g_malloc (sizeof (struct FileData));
g_assert (tmp != NULL);
if (tmp)
{
- tmp->next = file_stack;
- file_stack = tmp;
memcpy (tmp, ¤tfile, sizeof (struct FileData));
+ tmp->next = file_stack; /* insert the new one */
+ file_stack = tmp;
+ /* copy currentfile -> tmp */
tmp->yybuffer = YY_CURRENT_BUFFER;
yyin = newfile;
yy_switch_to_buffer (yy_create_buffer (yyin, YY_BUF_SIZE));
-
- strcpy (currentfile.name, filename);
- currentfile.line = 1;
- strcpy (currentfile.modulename, "");
- strcpy (currentfile.moduleprefix, "");
-
- return (1);
+ g_assert( strlen(filename) < FILEDATA_FILENAME_LENGTH);
+ if ( strlen(filename) < FILEDATA_FILENAME_LENGTH )
+ {
+ strcpy (currentfile.name, filename);
+ currentfile.line = 1;
+ strcpy (currentfile.modulename, "");
+ strcpy (currentfile.moduleprefix, "");
+ /*
+ dump_file_stack("After Push");
+ */
+ return (1);
+ }
}
/* out of memory */
@@ -543,24 +606,26 @@
if (file_stack == NULL)
{
+ /*
+ printf ("\npop_file() - NULL stack.\n");
+ */
return (0);
}
tmp = file_stack;
- /* printf ("pop_file() - Done with file named: %s\n", file_stack->name); */
-
- file_stack = file_stack->next;
/*
- if (file_stack != NULL)
- printf ("pop_file() - Pop file named: %s\n", file_stack->name);
- else
- printf ("pop_file() - Pop file named: NULL\n");
+ printf ("\npop_file() - Done with file named: %s\n", currentfile.name);
+ printf ("pop_file() - Make %s currentfile.\n", tmp->name);
+ dump_file_stack("Before Pop");
*/
+ file_stack = file_stack->next;
memcpy (¤tfile, tmp, sizeof (struct FileData));
yy_delete_buffer (YY_CURRENT_BUFFER);
yy_switch_to_buffer (tmp->yybuffer);
g_free (tmp);
currentfile.next = NULL;
-
+ /*
+ dump_file_stack("After Pop");
+ */
return (1);
}
@@ -642,12 +707,12 @@
ptr2 = g_basename( name2);
g_assert( ptr1 );
g_assert( ptr2 );
- /*
+/*
printf( "compare_file_name_only() - file 1: %s\n", name1);
printf( "compare_file_name_only() - file 2: %s\n", name2);
printf( "compare_file_name_only() - base 1: %s\n", ptr1);
printf( "compare_file_name_only() - base 2: %s\n", ptr2);
- */
+*/
if ( strcasecmp( ptr1, ptr2) == 0)
{
/* printf("compare_file_name_only() - true\n"); */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/lib/classdefs classdata.c gcdparser.h...,
Neil Tiffin <=