diff lwcc/cpp.c @ 304:d85d173ba120 ccdev

Checkpoint lwcc development - preprocessor is runnable but nonfunctional The preprocessor is currently runnable but doesn't actually do anything useful. This is just a checkpoint.
author William Astle <lost@l-w.ca>
date Tue, 17 Sep 2013 19:33:41 -0600
parents 83fcc1ed6ad6
children 54f213c8fb81
line wrap: on
line diff
--- a/lwcc/cpp.c	Tue Sep 17 19:32:14 2013 -0600
+++ b/lwcc/cpp.c	Tue Sep 17 19:33:41 2013 -0600
@@ -28,6 +28,7 @@
 #include <lw_string.h>
 
 #include "cpp.h"
+#include "strpool.h"
 
 struct token *preproc_lex_next_token(struct preproc_info *);
 
@@ -49,7 +50,8 @@
 	
 	pp = lw_alloc(sizeof(struct preproc_info));
 	memset(pp, 0, sizeof(struct preproc_info));
-	pp -> fn = lw_strdup(fn);
+	pp -> strpool = strpool_create();
+	pp -> fn = strpool_strdup(pp -> strpool, fn);
 	pp -> fp = fp;
 	pp -> ra = CPP_NOUNG;
 	pp -> ppeolseen = 1;
@@ -112,7 +114,6 @@
 
 void preproc_finish(struct preproc_info *pp)
 {
-	lw_free((void *)(pp -> fn));
 	fclose(pp -> fp);
 	if (pp -> curtok)
 		token_free(pp -> curtok);
@@ -121,6 +122,7 @@
 		preproc_next_token(pp);
 		token_free(pp -> curtok);
 	}
+	strpool_free(pp -> strpool);
 	lw_free(pp);
 }