]> git.sur5r.net Git - cc65/commitdiff
Added a compar function for file positions.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 24 Jan 2011 16:15:35 +0000 (16:15 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 24 Jan 2011 16:15:35 +0000 (16:15 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@4912 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/common/filepos.c
src/common/filepos.h

index ba53095149a31863a07c63bda9d646b97e9057c4..6613f8b3d3fa0b6c4146459d7ff944ce383894b4 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2011, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -54,3 +54,28 @@ void InitFilePos (FilePos* P)
 
 
 
+int CompareFilePos (const FilePos* P1, const FilePos* P2)
+/* Compare two file positions. Return zero if both are equal, return a value
+ * > 0 if P1 is greater and P2, and a value < 0 if P1 is less than P2. The
+ * compare rates file index over line over column.
+ */
+{
+    if (P1->Name > P2->Name) {    
+        return 1;
+    } else if (P1->Name < P2->Name) {
+        return -1;
+    } else if (P1->Line > P2->Line) {
+        return 1;
+    } else if (P1->Line < P2->Line) {
+        return -1;
+    } else if (P1->Col > P2->Col) {
+        return 1;
+    } else if (P1->Col < P2->Col) {
+        return -1;
+    } else {
+        return 0;
+    }
+}
+
+
+
index e84ebbba05845172f5870ca6012ade76ceb53d88..b9b2e402437e94fcad7f2a8c89532cc3f0c07aaf 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/* (C) 1998-2011, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -66,6 +66,12 @@ struct FilePos {
 void InitFilePos (FilePos* P);
 /* Initialize the file position (set all fields to zero) */
 
+int CompareFilePos (const FilePos* P1, const FilePos* P2);
+/* Compare two file positions. Return zero if both are equal, return a value
+ * > 0 if P1 is greater and P2, and a value < 0 if P1 is less than P2. The
+ * compare rates file index over line over column.
+ */
+
 
 
 /* End of filepos.h */