Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2007-10-30 02:13:19 UTC

Modified files:
  Tag: u2_10_12_branch
     ircd/s_conf.c ircd/ircd_lexer.l ChangeLog

Log message:

Convert lexer to read using fileio.[ch] functions (thanks, Solaris!).

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.209 ircu2.10/ChangeLog:1.710.2.210
--- ircu2.10/ChangeLog:1.710.2.209      Mon Oct 29 18:53:33 2007
+++ ircu2.10/ChangeLog  Mon Oct 29 19:13:09 2007
@@ -1,5 +1,15 @@
 2007-10-29  Michael Poole <[EMAIL PROTECTED]>
 
+       * ircd/ircd_lexer.l (YY_INPUT): Redefine to use fbgets().
+       (init_lexer): Return a value to indicate failure.  Use fbopen().
+       (deinit_lexer): New function.
+
+       * ircd/s_conf.c (read_configuration_file): Update extern
+       declarations.  Bail if init_lexer() fails.  Call deinit_lexer()
+       rather than directly munging yyin.
+
+2007-10-29  Michael Poole <[EMAIL PROTECTED]>
+
        * include/gline.h: Delete declaration of gline_propagate().
 
        * include/whocmds.h: Delete declaration of count_users().
Index: ircu2.10/ircd/ircd_lexer.l
diff -u ircu2.10/ircd/ircd_lexer.l:1.21.2.4 ircu2.10/ircd/ircd_lexer.l:1.21.2.5
--- ircu2.10/ircd/ircd_lexer.l:1.21.2.4 Sun Feb 25 07:41:48 2007
+++ ircu2.10/ircd/ircd_lexer.l  Mon Oct 29 19:13:09 2007
@@ -17,7 +17,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: ircd_lexer.l,v 1.21.2.4 2007/02/25 15:41:48 entrope Exp $
+ * $Id: ircd_lexer.l,v 1.21.2.5 2007/10/30 02:13:09 entrope Exp $
  */
 
 %{
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "config.h"
+#include "fileio.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
 #include "ircd_string.h"
@@ -185,22 +186,38 @@
   return tok ? tok->value : 0;
 }
 
-void
+static FBFILE *lexer_input;
+
+#undef YY_INPUT
+#define YY_INPUT(buf, res, size) res = (fbgets(buf, size, lexer_input) ? 
strlen(buf) : 0)
+
+int
 init_lexer(void)
 {
-  yyin = fopen(configfile, "r");
-  if (yyin == NULL)
+  lexer_input = fbopen(configfile, "r");
+  if (lexer_input == NULL)
   {
 #ifdef YY_FATAL_ERROR
     YY_FATAL_ERROR("Could not open the configuration file.");
 #else
     fprintf(stderr, "Could not open the configuration file.");
 #endif
+    return 0;
   }
 #ifdef YY_NEW_FILE
   YY_NEW_FILE;
 #endif
   lineno = 1;
+  return 1;
+}
+
+void deinit_lexer(void)
+{
+  if (lexer_input != NULL)
+  {
+    fbclose(lexer_input);
+    lexer_input = NULL;
+  }
 }
 
 %}
Index: ircu2.10/ircd/s_conf.c
diff -u ircu2.10/ircd/s_conf.c:1.81.2.8 ircu2.10/ircd/s_conf.c:1.81.2.9
--- ircu2.10/ircd/s_conf.c:1.81.2.8     Wed Apr  4 18:52:39 2007
+++ ircu2.10/ircd/s_conf.c      Mon Oct 29 19:13:09 2007
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief ircd configuration file driver
- * @version $Id: s_conf.c,v 1.81.2.8 2007/04/05 01:52:39 entrope Exp $
+ * @version $Id: s_conf.c,v 1.81.2.9 2007/10/30 02:13:09 entrope Exp $
  */
 #include "config.h"
 
@@ -816,9 +816,9 @@
 static int conf_error;
 /** When non-zero, indicates that the configuration file was loaded at least 
once. */
 static int conf_already_read;
-extern FILE *yyin;
 extern void yyparse(void);
-extern void init_lexer(void);
+extern int init_lexer(void);
+extern void deinit_lexer(void);
 
 /** Read configuration file.
  * @return Zero on failure, non-zero on success. */
@@ -827,11 +827,10 @@
   conf_error = 0;
   feature_unmark(); /* unmark all features for resetting later */
   clear_nameservers(); /* clear previous list of DNS servers */
-  /* Now just open an fd. The buffering isn't really needed... */
-  init_lexer();
+  if (!init_lexer())
+    return 0;
   yyparse();
-  fclose(yyin);
-  yyin = NULL;
+  deinit_lexer();
   feature_mark(); /* reset unmarked features */
   conf_already_read = 1;
   return 1;
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to