changeset 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 e1a028daceb9
children a7564d29fd53
files ChangeLog NEWS configure.in sm-archive.spec.in src/context.cpp src/context.h src/includes.h src/sm-archive.cpp src/sm-archive.h src/tokenizer.cpp src/tokenizer.h
diffstat 11 files changed, 592 insertions(+), 594 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 21 16:02:40 2008 -0700
+++ b/ChangeLog	Thu Jun 12 18:17:33 2008 -0700
@@ -1,3 +1,6 @@
+1.7 2008-06-12
+    Fedora 9 compile and const correctness.
+
 1.6 2008-03-21
     Add src/daemon* missing from source control.
     Switch to Mercurial source control.
--- a/NEWS	Fri Mar 21 16:02:40 2008 -0700
+++ b/NEWS	Thu Jun 12 18:17:33 2008 -0700
@@ -1,3 +1,4 @@
+1.7  2008-06-12 Fedora 9 compile and const correctness.
 1.6  2008-03-21 Add src/daemon* missing from source control.
 1.5  2007-08-24 GPL3. Can now remove original recipients.
 1.4  2007-02-07 more fixes for solaris
--- a/configure.in	Fri Mar 21 16:02:40 2008 -0700
+++ b/configure.in	Thu Jun 12 18:17:33 2008 -0700
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT(sm-archive,1.6,carl@five-ten-sg.com)
+AC_INIT(sm-archive,1.7,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 
--- a/sm-archive.spec.in	Fri Mar 21 16:02:40 2008 -0700
+++ b/sm-archive.spec.in	Thu Jun 12 18:17:33 2008 -0700
@@ -9,7 +9,6 @@
 Source:             http://www.five-ten-sg.com/%{name}/packages/%{name}-%{version}.tar.gz
 BuildRoot:          %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 URL:                http://www.five-ten-sg.com/%{name}/
-AutoReqProv:        no
 
 Requires(pre):          /usr/sbin/useradd
 Requires(pre):          /usr/bin/getent
@@ -19,7 +18,6 @@
 BuildRequires:          sendmail-devel >= 8.12.1
 Requires:               sendmail >= 8.12.1
 Requires:               sendmail-cf
-Requires:               libc.so.6, libgcc_s.so.1, libm.so.6, libpthread.so.0, libstdc++.so.6
 
 
 %description
@@ -44,7 +42,7 @@
 rm -rf $RPM_BUILD_ROOT
 make DESTDIR=$RPM_BUILD_ROOT install
 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
-mv -f $RPM_BUILD_ROOT%{_sysconfdir}/sm-archive/sm-archive   $RPM_BUILD_ROOT/etc/rc.d/init.d
+mv -f $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/%{name} $RPM_BUILD_ROOT/etc/rc.d/init.d
 mkdir -p $RPM_BUILD_ROOT/var/run/%{name}
 
 
@@ -85,7 +83,10 @@
 
 
 %changelog
-* Fri Mar 21 2008 Carl Byington <carl@five-ten-sg.com> - 1.6
+* Thu Jun 12 2008 Carl Byington <carl@five-ten-sg.com> - 1.7-1
+- Fedora 9 compile and const correctness.
+
+* Fri Mar 21 2008 Carl Byington <carl@five-ten-sg.com> - 1.6-1
 - changes for Fedora packaging guidelines
 
 * Fri Mar 10 2006 Carl Byington <carl@five-ten-sg.com> -1.0
--- a/src/context.cpp	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/context.cpp	Thu Jun 12 18:17:33 2008 -0700
@@ -8,13 +8,13 @@
 
 #include "includes.h"
 
-char *token_envfrom;
-char *token_include;
-char *token_lbrace;
-char *token_rbrace;
-char *token_rcptto;
-char *token_remove;
-char *token_semi;
+const char *token_envfrom;
+const char *token_include;
+const char *token_lbrace;
+const char *token_rbrace;
+const char *token_rcptto;
+const char *token_remove;
+const char *token_semi;
 
 string_set	all_strings;	// owns all the strings, only modified by the config loader thread
 const int maxlen = 1000;	// used for snprintf buffers
@@ -30,7 +30,7 @@
 }
 
 
-bool CONFIG::find(char *needle, string_set &haystack) {
+bool CONFIG::find(const char *needle, string_set &haystack) {
 	string_set::iterator i = haystack.find(needle);
 	if (i != haystack.end()) return true;		   // found user@domain.tld key
 	char *x = strchr(needle, '@');
@@ -48,7 +48,7 @@
 }
 
 
-char *CONFIG::find(char *needle, string_map &haystack) {
+const char *CONFIG::find(const char *needle, string_map &haystack) {
 	string_map::iterator i = haystack.find(needle);
 	if (i != haystack.end()) return (*i).second;		// found user@domain.tld key
 	char *x = strchr(needle, '@');
@@ -69,8 +69,8 @@
 void CONFIG::dump() {
 	printf("rcpt_to {\n");
 	for (string_map::iterator i=rcpt_to.begin(); i!=rcpt_to.end(); i++) {
-		char	 *to = (*i).first;
-		char *target = (*i).second;
+		const char	 *to = (*i).first;
+		const char *target = (*i).second;
 		if (!target) target = "\"\"";
 		bool rem = find_remove(to);
 		printf("    %s \t %s%s;\n", to, target, (rem) ? " remove" : "");
@@ -78,8 +78,8 @@
 	printf("};\n");
 	printf("env_from {\n");
 	for (string_map::iterator i=env_from.begin(); i!=env_from.end(); i++) {
-		char   *from = (*i).first;
-		char *target = (*i).second;
+		const char   *from = (*i).first;
+		const char *target = (*i).second;
 		if (!target) target = "\"\"";
 		printf("    %s \t %s;\n", from, target);
 	}
@@ -92,7 +92,7 @@
 //
 void discard(string_set &s) {
 	for (string_set::iterator i=s.begin(); i!=s.end(); i++) {
-		free(*i);
+		free((void*)*i);
 	}
 	s.clear();
 }
@@ -101,7 +101,7 @@
 ////////////////////////////////////////////////
 // helper to register a string in a string set
 //
-char* register_string(string_set &s, char *name) {
+const char* register_string(string_set &s, const char *name) {
 	string_set::iterator i = s.find(name);
 	if (i != s.end()) return *i;
 	char *x = strdup(name);
@@ -113,7 +113,7 @@
 ////////////////////////////////////////////////
 // register a global string
 //
-char* register_string(char *name) {
+const char* register_string(const char *name) {
 	return register_string(all_strings, name);
 }
 
@@ -128,9 +128,9 @@
 
 ////////////////////////////////////////////////
 //
-bool tsa(TOKEN &tok, char *token);
-bool tsa(TOKEN &tok, char *token) {
-	char *have = tok.next();
+bool tsa(TOKEN &tok, const char *token);
+bool tsa(TOKEN &tok, const char *token) {
+	const char *have = tok.next();
 	if (have == token) return true;
 	tok.token_error(token, have);
 	return false;
@@ -143,10 +143,10 @@
 bool parse_rcpt_to(TOKEN &tok, CONFIG &dc) {
 	if (!tsa(tok, token_lbrace)) return false;
 	while (true) {
-		char *have = tok.next();
+		const char *have = tok.next();
 		if (!have) break;
 		if (have == token_rbrace) break;
-		char *target = tok.next();
+		const char *target = tok.next();
 		dc.add_to(have, target);
 		target = tok.next();
 		if (target == token_remove) {
@@ -168,14 +168,14 @@
 bool parse_env_from(TOKEN &tok, CONFIG &dc) {
 	if (!tsa(tok, token_lbrace)) return false;
 	while (true) {
-		char *have = tok.next();
+		const char *have = tok.next();
 		if (!have) break;
 		if (have == token_rbrace) break;
 		if (have == token_semi) {
 			// optional separators
 		}
 		else {
-			char *target = tok.next();
+			const char *target = tok.next();
 			dc.add_from(have, target);
 		}
 	}
@@ -186,10 +186,10 @@
 ////////////////////////////////////////////////
 // parse a config file
 //
-bool load_conf(CONFIG &dc, char *fn) {
+bool load_conf(CONFIG &dc, const char *fn) {
 	TOKEN tok(fn, &dc.config_files);
 	while (true) {
-		char *have = tok.next();
+		const char *have = tok.next();
 		if (!have) break;
 		if (have == token_envfrom) {
 			if (!parse_env_from(tok, dc)) {
--- a/src/context.h	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/context.h	Thu Jun 12 18:17:33 2008 -0700
@@ -8,11 +8,7 @@
 #ifndef context_include
 #define context_include
 
-#include "tokenizer.h"
-#include <map>
-
-
-typedef map<char *, char *, ltstr>		  string_map;
+typedef map<const char *, const char *, ltstr>  string_map;
 
 struct CONFIG {
 	// the only mutable stuff once it has been loaded from the config file
@@ -27,33 +23,33 @@
 
 	CONFIG();
 	~CONFIG();
-	void		add_from(char *from, char *target)		{env_from[from] = target;	   };
-	void		add_to(char *to, char *target)			{rcpt_to[to]	= target;	   };
-	void		add_remove(char *to)					{rcpt_remove.insert(to);	   };
-	char *		find_from(char *from)					{return find(from, env_from);  };
-	char *		find_to(char *to)						{return find(to, rcpt_to);	   };
-	bool		find_remove(char *to)					{return find(to, rcpt_remove); };
-	bool		find(char *needle, string_set &haystack);
-	char *		find(char *needle, string_map &haystack);
+    void        add_from(const char *from, const char *target)  {env_from[from] = target;      };
+    void        add_to(const char *to, const char *target)      {rcpt_to[to]    = target;      };
+    void        add_remove(const char *to)                      {rcpt_remove.insert(to);       };
+    const char *find_from(const char *from)                     {return find(from, env_from);  };
+    const char *find_to(const char *to)                         {return find(to, rcpt_to);     };
+    bool        find_remove(const char *to)                     {return find(to, rcpt_remove); };
+    bool        find(const char *needle, string_set &haystack);
+    const char *find(const char *needle, string_map &haystack);
 	void		dump();
 };
 
-extern char *token_envfrom;
-extern char *token_include;
-extern char *token_lbrace;
-extern char *token_rbrace;
-extern char *token_rcptto;
-extern char *token_remove;
-extern char *token_semi;
+extern const char *token_envfrom;
+extern const char *token_include;
+extern const char *token_lbrace;
+extern const char *token_rbrace;
+extern const char *token_rcptto;
+extern const char *token_remove;
+extern const char *token_semi;
 
 extern string_set	all_strings;	// owns all the strings, only modified by the config loader thread
 
 void discard(string_set &s);
-char* register_string(string_set &s, char *name);
-char* register_string(char *name);
+const char* register_string(string_set &s, const char *name);
+const char* register_string(const char *name);
 void  clear_strings();
-CONFIG *parse_config(char *fn);
-bool  load_conf(CONFIG &dc, char *fn);
+CONFIG *parse_config(const char *fn);
+bool  load_conf(CONFIG &dc, const char *fn);
 void  token_init();
 
 #endif
--- a/src/includes.h	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/includes.h	Thu Jun 12 18:17:33 2008 -0700
@@ -2,6 +2,15 @@
 	#include "config.h"
 #endif
 
+#include <map>
+#include <fstream>
+#include <list>
+#include <set>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+
 #include "tokenizer.h"
 #include "context.h"
 #include "sm-archive.h"
--- a/src/sm-archive.cpp	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/sm-archive.cpp	Thu Jun 12 18:17:33 2008 -0700
@@ -87,12 +87,12 @@
 void mlfiPriv::reset(bool final) {
 	targets.clear();
 	for (string_set::iterator i=removal.begin(); i!=removal.end(); i++) {
-		char *remove = (*i);
-		free(remove);
+		const char *remove = (*i);
+		free((void*)remove);
 	}
 	removal.clear();
-	if (mailaddr) free(mailaddr);
-	if (queueid)  free(queueid);
+	if (mailaddr) free((void*)mailaddr);
+	if (queueid)  free((void*)queueid);
 	if (!final) {
 		mailaddr = NULL;
 		queueid  = NULL;
@@ -105,7 +105,7 @@
 ////////////////////////////////////////////////
 // syslog a message
 //
-void my_syslog(mlfiPriv *priv, char *text) {
+void my_syslog(mlfiPriv *priv, const char *text) {
 	char buf[maxlen];
 	if (priv) {
 		snprintf(buf, sizeof(buf), "%s: %s", priv->queueid, text);
@@ -125,7 +125,7 @@
 	}
 }
 
-void my_syslog(char *text) {
+void my_syslog(const char *text) {
 	my_syslog(NULL, text);
 }
 
@@ -136,8 +136,8 @@
 // as the mail client sent it. We dup the string and convert
 // the duplicate to lower case.
 //
-char *to_lower_string(char *email);
-char *to_lower_string(char *email) {
+const char *to_lower_string(const char *email);
+const char *to_lower_string(const char *email) {
 	int n = strlen(email)-2;
 	if (n < 1) return strdup(email);
 	char *key = strdup(email+1);
@@ -167,8 +167,8 @@
 	return SMFIS_CONTINUE;
 }
 
-void add_target(mlfiPriv &priv, char *target);
-void add_target(mlfiPriv &priv, char *target)
+void add_target(mlfiPriv &priv, const char *target);
+void add_target(mlfiPriv &priv, const char *target)
 {
 	if (target) {
 		string_set::iterator i = priv.targets.find(target);
@@ -176,8 +176,8 @@
 	}
 }
 
-void add_remove(mlfiPriv &priv, char *remove);
-void add_remove(mlfiPriv &priv, char *remove)
+void add_remove(mlfiPriv &priv, const char *remove);
+void add_remove(mlfiPriv &priv, const char *remove)
 {
 	if (remove) {
 		string_set::iterator i = priv.removal.find(remove);
@@ -189,18 +189,18 @@
 {
 	mlfiPriv &priv = *MLFIPRIV;
 	CONFIG &dc = *priv.pc;
-	if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, "i"));
-	char *rcptaddr	= to_lower_string(rcpt[0]);
+	if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, (char*)"i"));
+	const char *rcptaddr	= to_lower_string(rcpt[0]);
 	if (debug_syslog > 1) {
 		char msg[maxlen];
 		snprintf(msg, sizeof(msg), "from <%s> to <%s>", priv.mailaddr, rcptaddr);
 		my_syslog(&priv, msg);
 	}
-	char *target = dc.find_to(rcptaddr);
+	const char *target = dc.find_to(rcptaddr);
 	add_target(priv, target);
 	bool remove  = dc.find_remove(rcptaddr);
 	if (remove) add_remove(priv, strdup(rcptaddr));
-	free(rcptaddr);
+	free((void*)rcptaddr);
 	return SMFIS_CONTINUE;
 }
 
@@ -208,11 +208,11 @@
 {
 	mlfiPriv &priv = *MLFIPRIV;
 	CONFIG &dc = *priv.pc;
-	char *target = dc.find_from(priv.mailaddr);
+	const char *target = dc.find_from(priv.mailaddr);
 	add_target(priv, target);
 	for (string_set::iterator i=priv.targets.begin(); i!=priv.targets.end(); i++) {
 		target = (*i);
-		smfi_addrcpt(ctx, target);
+		smfi_addrcpt(ctx, (char*)target);
 		if (debug_syslog > 1) {
 			char msg[maxlen];
 			snprintf(msg, sizeof(msg), "adding recipient <%s>", target);
@@ -220,8 +220,8 @@
 		}
 	}
 	for (string_set::iterator i=priv.removal.begin(); i!=priv.removal.end(); i++) {
-		char *remove = (*i);
-		smfi_delrcpt(ctx, remove);
+		const char *remove = (*i);
+		smfi_delrcpt(ctx, (char*)remove);
 		if (debug_syslog > 1) {
 			char msg[maxlen];
 			snprintf(msg, sizeof(msg), "removing recipient <%s>", remove);
@@ -251,7 +251,7 @@
 
 struct smfiDesc smfilter =
 {
-	"SM-ARCHIVE",       // filter name
+	(char*)"SM-ARCHIVE",// filter name
 	SMFI_VERSION,		// version code -- do not change
 	SMFIF_ADDRCPT | \
 	SMFIF_DELRCPT,		// flags
@@ -306,7 +306,7 @@
 		struct stat st;
 		bool reload = false;
 		for (string_set::iterator i=dc.config_files.begin(); i!=dc.config_files.end(); i++) {
-			char *fn = *i;
+			const char *fn = *i;
 			if (stat(fn, &st))			 reload = true; // file disappeared
 			else if (st.st_mtime > then) reload = true; // file modified
 			if (reload) break;
@@ -335,8 +335,8 @@
 }
 
 
-void usage(char *prog);
-void usage(char *prog)
+void usage(const char *prog);
+void usage(const char *prog)
 {
 	fprintf(stderr, "Usage: %s  [-d [level]] [-c] -p sm-sock-addr [-t timeout]\n", prog);
 	fprintf(stderr, "where sm-sock-addr is for the connection to sendmail\n");
@@ -349,8 +349,8 @@
 
 
 
-void setup_socket(char *sock);
-void setup_socket(char *sock) {
+void setup_socket(const char *sock);
+void setup_socket(const char *sock) {
 	unlink(sock);
 	//	sockaddr_un addr;
 	//	memset(&addr, '\0', sizeof addr);
--- a/src/sm-archive.h	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/sm-archive.h	Thu Jun 12 18:17:33 2008 -0700
@@ -8,8 +8,6 @@
 #ifndef smarchive_include
 #define smarchive_include
 
-#include "context.h"
-
 extern int debug_syslog;
 
 ////////////////////////////////////////////////
@@ -20,8 +18,8 @@
 	// connection specific data
 	CONFIG	*pc;			// global filtering configuration
 	// message specific data
-	char		*mailaddr;	// envelope from value
-	char		*queueid;	// sendmail queue id
+    const char  *mailaddr;  // envelope from value
+    const char  *queueid;   // sendmail queue id
 	string_set	targets;	// targets to add at eom, strings are owned by the config
 	string_set	removal;	// targets to remove at eom, strings are owned here
 	mlfiPriv();
@@ -29,7 +27,7 @@
 	void reset(bool final = false); // for a new message
 };
 
-void my_syslog(mlfiPriv *priv, char *text);
-void my_syslog(char *text);
+void my_syslog(mlfiPriv *priv, const char *text);
+void my_syslog(const char *text);
 
 #endif
--- a/src/tokenizer.cpp	Fri Mar 21 16:02:40 2008 -0700
+++ b/src/tokenizer.cpp	Thu Jun 12 18:17:33 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,11 +301,11 @@
 
 void TOKEN::pop() {
 	ifstream *is = streams.front();
-	char *fn = filenames.front();
+    const char *fn = filenames.front();
 	streams.pop_front();
-	filenames.pop_front();
 	filenamess.erase(fn);
-	linenumbers.pop_front();
+    if (filenames.size() > 1)   filenames.pop_front();
+    if (linenumbers.size() > 1) linenumbers.pop_front();
 	is->close();
 	delete is;
 }
@@ -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,15 +363,15 @@
 }
 
 
-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;
 	}
 	if (streams.empty()) return NULL;
 	const int PENDING_LIMIT = 1000;
-	static u_char buffer[PENDING_LIMIT];
+    u_char buffer[PENDING_LIMIT];
 	int count = 0;
 	state st = s_init;
 	while (true) {
@@ -437,7 +437,7 @@
 
 			default: {
 				token_error();
-				token_error("unknown state %d %s \n", st, " ");
+                token_error("unknown state %d %s", st, " ");
 			} break;
 		}
 		if (st == s_init) break;
@@ -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') {
@@ -509,19 +509,19 @@
 
 void TOKEN::token_error(const char *want, const char *have) {
 	token_error();
-	token_error("expecting %s, found %s \n", want, have);
+    token_error("expecting %s, found %s", want, have);
 }
 
 
 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("\n    included from line %d in file %s -- ", li, fn);
+            token_error("    included from line %d in file %s -- ", li, fn);
 		}
 	}
 }
--- 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