Remove sunrpc compatibility
[openafs.git] / src / rxgen / rpc_scan.c
index 1137068..aeb0940 100644 (file)
@@ -6,50 +6,41 @@
  * may copy or modify Sun RPC without charge, but are not authorized
  * to license or distribute it to anyone else except as part of a product or
  * program developed by the user.
- * 
+ *
  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
+ *
  * Sun RPC is provided with no support and without any obligation on the
  * part of Sun Microsystems, Inc. to assist in its use, correction,
  * modification or enhancement.
- * 
+ *
  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  * OR ANY PART THEREOF.
- * 
+ *
  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  * or profits or other special, indirect and consequential damages, even if
  * Sun has been advised of the possibility of such damages.
- * 
+ *
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
 
 /*
- * rpc_scan.c, Scanner for the RPC protocol compiler 
- * Copyright (C) 1987, Sun Microsystems, Inc. 
+ * rpc_scan.c, Scanner for the RPC protocol compiler
+ * Copyright (C) 1987, Sun Microsystems, Inc.
  */
 
 /* Portions Copyright (c) 2003 Apple Computer, Inc. */
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
+#include <roken.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <ctype.h>
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
+
 #include "rpc_scan.h"
 #include "rpc_parse.h"
 #include "rpc_util.h"
@@ -75,7 +66,7 @@ static void deverbatim(void);
 
 
 /*
- * scan expecting 1 given token 
+ * scan expecting 1 given token
  */
 void
 scan(tok_kind expect, token * tokp)
@@ -87,7 +78,7 @@ scan(tok_kind expect, token * tokp)
 }
 
 /*
- * scan expecting 2 given tokens 
+ * scan expecting 2 given tokens
  */
 void
 scan2(tok_kind expect1, tok_kind expect2, token * tokp)
@@ -99,7 +90,7 @@ scan2(tok_kind expect1, tok_kind expect2, token * tokp)
 }
 
 /*
- * scan expecting 3 given token 
+ * scan expecting 3 given token
  */
 void
 scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token * tokp)
@@ -127,7 +118,7 @@ scan4(tok_kind expect1, tok_kind expect2, tok_kind expect3, tok_kind expect4,
 }
 
 /*
- * scan expecting a constant, possibly symbolic 
+ * scan expecting a constant, possibly symbolic
  */
 void
 scan_num(token * tokp)
@@ -143,7 +134,7 @@ scan_num(token * tokp)
 
 
 /*
- * Peek at the next token 
+ * Peek at the next token
  */
 void
 peek(token * tokp)
@@ -154,7 +145,7 @@ peek(token * tokp)
 
 
 /*
- * Peek at the next token and scan it if it matches what you expect 
+ * Peek at the next token and scan it if it matches what you expect
  */
 int
 peekscan(tok_kind expect, token * tokp)
@@ -170,7 +161,7 @@ peekscan(tok_kind expect, token * tokp)
 
 
 /*
- * Get the next token, printing out any directive that are encountered. 
+ * Get the next token, printing out any directive that are encountered.
  */
 void
 get_token(token * tokp)
@@ -240,7 +231,7 @@ get_token(token * tokp)
     }
 
     /*
-     * 'where' is not whitespace, comment or directive Must be a token! 
+     * 'where' is not whitespace, comment or directive Must be a token!
      */
     switch (*where) {
     case ':':
@@ -353,13 +344,13 @@ findstrconst(char **str, char **val)
 
     p = *str;
     do {
-       *p++;
+       p++;
     } while (*p && *p != '"');
     if (*p == 0) {
        error("unterminated string constant");
     }
     p++;
-    size = p - *str;
+    size = (int)(p - *str);
     *val = alloc(size + 1);
     (void)strncpy(*val, *str, size);
     (*val)[size] = 0;
@@ -383,7 +374,7 @@ findconst(char **str, char **val)
            p++;
        } while (isdigit(*p));
     }
-    size = p - *str;
+    size = (int)(p - *str);
     *val = alloc(size + 1);
     (void)strncpy(*val, *str, size);
     (*val)[size] = 0;
@@ -412,8 +403,6 @@ static token symbols[] = {
     {TOK_FLOAT, "float"},
     {TOK_DOUBLE, "double"},
     {TOK_STRING, "string"},
-    {TOK_PROGRAM, "program"},
-    {TOK_VERSION, "version"},
     {TOK_PACKAGE, "package"},
     {TOK_PREFIX, "prefix"},
     {TOK_STATINDEX, "statindex"},
@@ -442,7 +431,7 @@ findkind(char **mark, token * tokp)
 
     str = *mark;
     for (s = symbols; s->kind != TOK_EOF; s++) {
-       len = strlen(s->str);
+       len = (int)strlen(s->str);
        if (strncmp(str, s->str, len) == 0) {
            if (!isalnum(str[len]) && str[len] != '_') {
                tokp->kind = s->kind;
@@ -526,6 +515,7 @@ docppline(char *line, int *lineno, char **fname)
     *p = 0;
     if (*file == 0) {
        *fname = NULL;
+       free(file);
     } else {
        *fname = file;
     }