diff src/tokenizer.cpp @ 214:82886d4dd71f stable-6-0-19

Fixes to compile on Fedora 9 and for const correctness.
author Carl Byington <carl@five-ten-sg.com>
date Tue, 10 Jun 2008 08:58:42 -0700
parents 44ffef730bc4
children f5b394bec28c
line wrap: on
line diff
--- a/src/tokenizer.cpp	Wed Apr 30 13:11:32 2008 -0700
+++ b/src/tokenizer.cpp	Tue Jun 10 08:58:42 2008 -0700
@@ -287,7 +287,7 @@
 };
 
 
-TOKEN::TOKEN(char *fn, string_set *includes) {
+TOKEN::TOKEN(const char *fn, string_set *includes) {
 	pushed = false;
 	include_files = includes;
 	include(fn);
@@ -301,7 +301,7 @@
 
 void TOKEN::pop() {
 	ifstream *is = streams.front();
-	char *fn = filenames.front();
+    const char *fn = filenames.front();
 	streams.pop_front();
 	filenamess.erase(fn);
 	if (filenames.size() > 1)	filenames.pop_front();
@@ -339,7 +339,7 @@
 }
 
 
-bool TOKEN::include(char *fn) {
+bool TOKEN::include(const char *fn) {
 	string_set::iterator i = filenamess.find(fn);
 	if (i != filenamess.end()) {
 		token_error("redundant or recursive include file detected");
@@ -363,9 +363,9 @@
 }
 
 
-char *TOKEN::next() {
+const char *TOKEN::next() {
 	if (!pending_tokens.empty()) {
-		char *t = pending_tokens.front();
+        const char *t = pending_tokens.front();
 		pending_tokens.pop_front();
 		return t;
 	}
@@ -445,10 +445,10 @@
 
 	buffer[count] = '\0';
 	if (count == 0) return NULL;
-	char *t = register_string((char*)buffer);
+    const char *t = register_string((char*)buffer);
 	if (t == token_include) {
-		char *f = next();	// should be file name
-		char *s = next();	// should be semicolon
+        const char *f = next();   // should be file name
+        const char *s = next();   // should be semicolon
 		if (s == token_semi) {
 			include(f);
 			return next();
@@ -464,7 +464,7 @@
 
 
 int TOKEN::nextint() {
-	char *t = next();
+    const char *t = next();
 	char *e;
 	long i = strtol(t, &e, 10);
 	if (*e != '\0') {
@@ -516,10 +516,10 @@
 void TOKEN::token_error() {
 	token_error("syntax error at line %d in file %s -- ", cur_line(), cur_fn());
 	line_list::iterator   j = linenumbers.begin();
-	string_list::iterator i = filenames.begin();
+    string_list::const_iterator i = filenames.begin();
 	for (; i!=filenames.end(); i++,j++) {
 		if (i != filenames.begin()) {
-			char *fn = (*i);
+            const char *fn = (*i);
 			int   li = (*j);
 			token_error("    included from line %d in file %s -- ", li, fn);
 		}