]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nfs/xio.c
Only treat '#' as starting a comment when at the start of a token
[nfs-utils.git] / support / nfs / xio.c
index 9bb5100d09f4e392f12a6816ead5c62e17df1c54..1ce515727a0d7330143b4f7df478e12d414aa883 100644 (file)
@@ -6,7 +6,9 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <sys/fcntl.h>
 #include <string.h>
@@ -93,6 +95,11 @@ xgettok(XFILE *xfp, char sepa, char *tok, int len)
 
        while (i < len && (c = xgetc(xfp)) != EOF &&
               (quoted || (c != sepa && !isspace(c)))) {
+               if (!quoted && i == 0 && c == '#') {
+                       c = xskipcomment(xfp);
+                       xfp->x_line++;
+                       break;
+               }
                if (c == '"') {
                        quoted = !quoted;
                        continue;
@@ -136,8 +143,6 @@ xgetc(XFILE *xfp)
                ungetc(c, xfp->x_fp);
                return ' ';
        }
-       if (c == '#')
-               c = xskipcomment(xfp);
        if (c == '\n')
                xfp->x_line++;
        return c;
@@ -160,7 +165,7 @@ xskip(XFILE *xfp, char *str)
        int     c;
 
        while ((c = xgetc(xfp)) != EOF && strchr(str, c));
-       ungetc(c, xfp->x_fp);
+       xungetc(c, xfp);
 }
 
 char