diff src/tokenizer.h @ 19:b24369330483 stable-1-0-7

Fedora 9 compile and const correctness.
author Carl Byington <carl@five-ten-sg.com>
date Thu, 12 Jun 2008 18:17:33 -0700
parents 75e1a9bcbc2e
children
line wrap: on
line diff
--- a/src/tokenizer.h	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/tokenizer.h	Thu Jun 12 18:17:33 2008 -0700
@@ -5,27 +5,18 @@
 http://www.gnu.org/licenses/gpl-3.0.txt
 
 */
-#ifndef tokenizer_include
-#define tokenizer_include
-
-#include <fstream>
-#include <list>
-#include <set>
-#include <stdio.h>
-#include <ctype.h>
-
 
 using namespace std;
 
 struct ltstr {
-	bool operator()(char* s1, char* s2) const {
+    bool operator()(const char* s1, const char* s2) const {
 		return strcmp(s1, s2) < 0;
 	}
 };
 
 typedef list<ifstream *>	stream_list;
-typedef list<char *>		string_list;
-typedef set<char *, ltstr>	string_set;
+typedef list<const char *>          string_list;
+typedef set<const char *, ltstr>    string_set;
 typedef list<int>			line_list;
 
 class TOKEN {
@@ -43,15 +34,15 @@
 	void push_char(u_char c);
 
 public:
-	TOKEN(char *fn, string_set *includes);
+    TOKEN(const char *fn, string_set *includes);
 	~TOKEN();
-	bool	include(char *fn);
-	char	*next();			// return next token
+    bool        include(const char *fn);
+    const char  *next();            // return next token
 	int 	nextint();
 	void	skipeol();			// skip to eol
-	void	push(char *token)			{pending_tokens.push_front(token);};
-	char	*cur_fn()					{return filenames.front();};
-	int 	cur_line()					{return linenumbers.front();};
+    void        push(const char *token) {pending_tokens.push_front(token);};
+    const char  *cur_fn()               {return filenames.empty()   ? "" : filenames.front();};
+    int         cur_line()              {return linenumbers.empty() ? 0  : linenumbers.front();};
 	void	token_error(const char *err);
 	void	token_error(const char *fmt, int d, const char *s);
 	void	token_error(const char *fmt, const char *t, const char *h);
@@ -59,4 +50,3 @@
 	void	token_error();
 };
 
-#endif