Whamcloud - gitweb
tst_libext2fs: Avoid multiple definition of global variables
[tools/e2fsprogs.git] / lib / ext2fs / version.c
index c0e6351..f8c8acf 100644 (file)
@@ -4,11 +4,12 @@
  * Copyright (C) 1997 Theodore Ts'o.
  *
  * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
  * %End-Header%
  */
 
+#include "config.h"
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 #include <stdio.h>
 #include <ctype.h>
 
-#if EXT2_FLAT_INCLUDES
 #include "ext2_fs.h"
-#else
-#include <linux/ext2_fs.h>
-#endif
-
 #include "ext2fs.h"
 
 #include "../../version.h"
@@ -32,11 +28,17 @@ static const char *lib_date = E2FSPROGS_DATE;
 int ext2fs_parse_version_string(const char *ver_string)
 {
        const char *cp;
-       int version = 0;
+       int version = 0, dot_count = 0;
 
        for (cp = ver_string; *cp; cp++) {
+               if (*cp == '.') {
+                       if (dot_count++)
+                               break;
+                       else
+                               continue;
+               }
                if (!isdigit(*cp))
-                       continue;
+                       break;
                version = (version * 10) + (*cp - '0');
        }
        return version;