1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 17:29:50 +00:00

Added a compar function for file positions.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4912 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-01-24 16:15:35 +00:00
parent 3b59a8ca6f
commit a7bd3ad0db
2 changed files with 36 additions and 5 deletions

View 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;
}
}

View 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 */