diff options
| author | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2014-03-02 13:53:33 -0500 |
|---|---|---|
| committer | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2014-03-02 13:53:33 -0500 |
| commit | 9155a365e1e0a7e9fec47447f86af09117b30edb (patch) | |
| tree | 6c54cfee6f4784aa777cef186dbca9aa1f856efd /fcomp.c | |
| parent | ffe739eeb12d1bf9dadb2144e95fef79820c6844 (diff) | |
| download | prism-9155a365e1e0a7e9fec47447f86af09117b30edb.tar.gz prism-9155a365e1e0a7e9fec47447f86af09117b30edb.zip | |
Added support for building with GNU C (Linux, etc.). Fixed minor bugs in diff routine.
Diffstat (limited to 'fcomp.c')
| -rw-r--r-- | fcomp.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -60,8 +60,9 @@ int lines = 0; buf = (char *)malloc(256*sizeof(char));
if(buf == NULL)
return PRET_ERROR;
-
- while(fgets(buf,100,fp) != NULL)
+ memset(buf, 0, 256);
+
+ while(fgets(buf,255,fp) != NULL)
{
if (lines >= MAXLINES) {
fatal("file is to large for diff");
@@ -174,12 +175,14 @@ int compare_files(const char *fname1, const char *fname2) m = in_file(fname1,A);
n = in_file(fname2,B);
- for (row=0 ; row<m && row < n && strcmp(A[row],B[row]) == 0 ; ++row)
- ;
+ for(row=0; row < m && row < n && strcmp(A[row],B[row]) == 0; ++row);
+
last_d[ORIGIN] = row;
script[ORIGIN] = NULL;
+
lower = (row == m) ? ORIGIN + 1 : ORIGIN - 1;
upper = (row == n) ? ORIGIN - 1 : ORIGIN + 1;
+
if (lower > upper)
{
printf(" the files are identical\n");
@@ -237,4 +240,3 @@ int compare_files(const char *fname1, const char *fname2) exceed(d);
return PRET_ERROR;
}
-
|
