* amd/sun_map_parse.y: Moved license below special yacc bracket to
authorDaniel Ottavio <ottavio@fsl.cs.sunysb.edu>
Wed, 10 Aug 2005 01:39:19 +0000 (01:39 +0000)
committerDaniel Ottavio <ottavio@fsl.cs.sunysb.edu>
Wed, 10 Aug 2005 01:39:19 +0000 (01:39 +0000)
be portable with HPUX's yacc.  Clean up externs.

* amd/sun_map_tok.l: Moved license below special lex bracket to be
portable with HPUX's lex.  Fixed definitions to allow for a
non-flex lex to parse strings instead of files.  Added some casts
to strlcpy usage to silence warnings.  Moved the % options because
HPUX was complaining,

ChangeLog
amd/sun_map_parse.y
amd/sun_map_tok.l

index 6f794418b4a94e6d5e94ba2bdb1724e32446c067..0086ade9007f7efbf91fe89ca52fc481fcb44088 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-08-09  Daniel P. Ottavio  <dottavio@ic.sunysb.edu>
+
+       * amd/sun_map_parse.y: Moved license below special yacc bracket to
+       be portable with HPUX's yacc.  Clean up externs.
+
+       * amd/sun_map_tok.l: Moved license below special lex bracket to be
+       portable with HPUX's lex.  Fixed definitions to allow for a
+       non-flex lex to parse strings instead of files.  Added some casts
+       to strlcpy usage to silence warnings.  Moved the % options because
+       HPUX was complaining,
+       
 2005-08-08  Daniel P. Ottavio  <dottavio@ic.sunysb.edu>
 
        * amd/sun_map_tok.l: Applied some definition goop to handle the
index 433b8a1d964b698ebcb0dc5e7794322ecee3c863..c420179cb1df80b6fff603ff76f3d8b19d99357e 100644 (file)
@@ -1,3 +1,4 @@
+%{
 /*
  * Copyright (c) 1997-2005 Erez Zadok
  * Copyright (c) 2005 Daniel P. Ottavio
@@ -42,8 +43,6 @@
  *
  */
 
-%{
-
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif /* HAVE_CONFIG_H */
 #include <sun_map.h>
 
 extern int sun_map_lex(void);
-extern int sun_map_error(const char* s);
+extern int sun_map_error(const char *);
 extern void sun_map_tok_setbuff(const char *);
 extern int sun_map_parse(void);
 
-struct sun_entry *sun_map_parse_read(const char *map_data);
+struct sun_entry *sun_map_parse_read(const char *);
 
 static struct sun_list *sun_entry_list = NULL;
 static struct sun_list *sun_include_list = NULL;
index bfc2eaa7a77945d8134ed1f9dcd1cf3b390a8b28..b1fe86d759a621f39804b88cd098736449f08c63 100644 (file)
@@ -1,3 +1,4 @@
+%{
 /*
  * Copyright (c) 1997-2005 Erez Zadok
  * Copyright (c) 2005 Daniel P. Ottavio
@@ -42,8 +43,6 @@
  *
  */
 
-%{
-
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif /* HAVE_CONFIG_H */
@@ -81,7 +80,6 @@
  * instead of a file. Each version of lex has it's
  * own way of doing this (sigh).
  */
-#ifdef FLEX_SCANNER
 
 /* assign the buffer to parse */
 void sun_map_tok_setbuff(const char* buff);
@@ -89,6 +87,14 @@ void sun_map_tok_setbuff(const char* buff);
 /* buffer that contains the string to parse */
 const char *sun_map_tok_buff = NULL;
 
+#ifdef FLEX_SCANNER
+/* 
+ * The flex scanner uses the YY_INPUT to parse the input. 
+ * We need to redefine it so that it can parse strings.
+ * In addition to the above string buffer we need to have
+ * a position pointer and a end pointer.
+ */
+
 /* current position of the buffer */
 const char *sun_map_tok_pos = NULL;
 
@@ -100,8 +106,16 @@ int sun_map_input(char *buff, int maxsize);
 
 # undef YY_INPUT
 # define YY_INPUT(buff,result,maxsize) (result = sun_map_input(buff,maxsize))
-#else /* not FLEX_SCANNER */
-# warning "Currently flex is the only supported version of lex."
+
+#else
+/* 
+ * If this is not Flex than fall back to an AT&T style lex. 
+ * We can parse strings by redefining input and unput.
+ */
+#undef input
+#undef unput
+#define input()  (*(char *)sun_map_tok_buff++)
+#define unput(c) (*(char *)--sun_map_tok_buff = c) 
 
 #endif /* FLEX_SCANNER */
 
@@ -123,26 +137,25 @@ int sun_map_tokpos = 1;
 
 %}
 
+/* This option causes Solaris lex to fail.  Use flex.  See BUGS file */
+/* no need to use yyunput() */
+%option nounput
+
+/* allocate more output slots so lex scanners don't run out of mem */
+%o 1024
+
+
 WORD_REX       ([A-Za-z0-9_/&".""$"=""-"]+)|"*"
 COMMENT_REX    ^#.*\n
 WSPACE_REX     [ \t]*
 NEWLINE_REX    [ \t]*\n
 CONTINUE_REX   "\\"\n
 
-/*
- * This option causes Solaris lex to fail.  Use flex.  See BUGS file
- * no need to use yyunput()
- */
-%option nounput
-
-/* allocate more output slots so lex scanners don't run out of mem */
-%o 1024
-
 %%
 
 {WORD_REX}      {
                   sun_map_tokpos += yyleng;
-                  xstrlcpy(yylval.strval,yytext,sizeof(yylval.strval));
+                  xstrlcpy((char *)yylval.strval,(const char *)yytext,sizeof(yylval.strval));
                   return WORD;
                 }
 
@@ -202,6 +215,13 @@ sun_map_input(char *buff, int maxsize)
 
   return size;
 }
+#else 
+void
+sun_map_tok_setbuff(const char* buff)
+{
+  sun_map_tok_buff = buff;
+}
+
 #endif /* FLEX_SCANNER */
 
 /*