Skip to content

Commit

Permalink
Enable -test command-line param to work under Mac/Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
john-boyer-phd committed May 15, 2016
1 parent 95a8d8a commit a3a0acb
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 7 deletions.
15 changes: 13 additions & 2 deletions c/planarity.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@ See the LICENSE.TXT file for licensing information.

void ProjectTitle()
{
// This message is the main location of the version number.
// The format is major.minor.maintenance.tweak
// Major is for an overhaul (e.g. many features, data structure change)
// Minor is for feature addition, e.g. a new algorithm implementation added
// Maintenance is for functional revision, e.g. bug fix to algorithm implementation
// Tweak is for a non-functional revision, e.g. change of build scripts or testing code

// If the version here is increased, also increase it in configure.ac
// Furthermore, a change of Major, Minor or Maintenance here should cause a change
// of Current, Revision and/or Age as documented in configure.ac

Message("\n=================================================="
"\nThe Edge Addition Planarity Suite version 3.0.0.4"
"\nCopyright (c) 1997-2015 by John M. Boyer"
"\nThe Edge Addition Planarity Suite version 3.0.0.5"
"\nCopyright (c) 1997-2016 by John M. Boyer"
"\nContact info: jboyer at acm.org"
"\n=================================================="
"\n");
Expand Down
2 changes: 1 addition & 1 deletion c/planarity.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Prompt(char *message);

void SaveAsciiGraph(graphP theGraph, char *filename);

int FilesEqual(char *file1Name, char *file2Name);
int TextFilesEqual(char *file1Name, char *file2Name);

int GetEmbedFlags(char command);
char *GetAlgorithmName(char command);
Expand Down
4 changes: 2 additions & 2 deletions c/planarityCommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int runSpecificGraphTest(char *command, char *infileName)

if (Result == 0)
{
if (FilesEqual(testfileName, outfileName) == TRUE)
if (TextFilesEqual(testfileName, outfileName) == TRUE)
{
Message("Test succeeded (result equal to exemplar).\n");
unlink(outfileName);
Expand All @@ -309,7 +309,7 @@ int runSpecificGraphTest(char *command, char *infileName)

if (Result == 0)
{
if (FilesEqual(testfileName, outfileName) == TRUE)
if (TextFilesEqual(testfileName, outfileName) == TRUE)
{
Message("Test succeeded (secondary result equal to exemplar).\n");
unlink(outfileName);
Expand Down
64 changes: 63 additions & 1 deletion c/planarityUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,69 @@ void SaveAsciiGraph(graphP theGraph, char *filename)
/****************************************************************************
****************************************************************************/

int FilesEqual(char *file1Name, char *file2Name)
int TextFilesEqual(char *file1Name, char *file2Name)
{
FILE *infile1 = NULL, *infile2 = NULL;
int Result = TRUE;

infile1 = fopen(file1Name, "r");
infile2 = fopen(file2Name, "r");

if (infile1 == NULL || infile2 == NULL)
Result = FALSE;
else
{
int c1=0, c2=0;

// Read the first file to the end
while ((c1 = fgetc(infile1)) != EOF)
{
// Want to suppress distinction between lines ending with CRLF versus LF
if (c1 == '\r')
continue;

// Get a char from the second file, except suppress CR again
while ((c2 = fgetc(infile2)) == '\r')
;

// If we got a char from the first file, but not from the second
// then the second file is shorter, so files are not equal
if (c2 == EOF)
{
Result = FALSE;
break;
}

// If we got a char from second file, but not equal to char from
// first file, then files are not equal
if (c1 != c2)
{
Result = FALSE;
break;
}
}

// If we got to the end of the first file without breaking the loop...
if (c1 == EOF)
{
// Then, once again, suppress CRs first, and then...
while ((c2 = fgetc(infile2)) == '\r')
;
// Test whether or not the second file also ends, same as the first.
if (fgetc(infile2) != EOF)
Result = FALSE;
}
}

if (infile1 != NULL) fclose(infile1);
if (infile2 != NULL) fclose(infile2);
return Result;
}

/****************************************************************************
****************************************************************************/

int BinaryFilesEqual(char *file1Name, char *file2Name)
{
FILE *infile1 = NULL, *infile2 = NULL;
int Result = TRUE;
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT(planarity, 3.0.0.4, [email protected])
AC_INIT(planarity, 3.0.0.5, [email protected])
AM_INIT_AUTOMAKE([subdir-objects] [foreign])
AC_CONFIG_SRCDIR([c/])

Expand Down

0 comments on commit a3a0acb

Please sign in to comment.