Module Name:    othersrc
Committed By:   agc
Date:           Mon Sep  7 22:39:54 UTC 2015

Modified Files:
        othersrc/external/bsd/netdiff/dist: diffreg.c

Log Message:
fgetpos(3) and fsetpos(3) may work on opaque types, so don't rely on
being able to set individual fields in the fpos_t struct. Instead, just
use the and ftell(3) and fseek(3) components.

Also define __UNCONST() if it's not already been defined. Just in case.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 othersrc/external/bsd/netdiff/dist/diffreg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/netdiff/dist/diffreg.c
diff -u othersrc/external/bsd/netdiff/dist/diffreg.c:1.11 othersrc/external/bsd/netdiff/dist/diffreg.c:1.12
--- othersrc/external/bsd/netdiff/dist/diffreg.c:1.11	Wed Jan 16 01:50:19 2013
+++ othersrc/external/bsd/netdiff/dist/diffreg.c	Mon Sep  7 22:39:54 2015
@@ -120,6 +120,10 @@ __FBSDID("$FreeBSD$");
 #define USE_ARG(x)		/*LINTED*/(void)&(x)
 #endif
 
+#ifndef __UNCONST
+#define __UNCONST(a)		((void *)(unsigned long)(const void *)(a))
+#endif
+
 #ifdef ST_MTIM_NSEC
 # define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC)
 #else
@@ -398,28 +402,6 @@ diff_getc(diff_t *diff, file_t *f)
 	return DIFF_GET_FLAG(diff, 'i') ? tolower(ch) : ch;
 }
 
-static int
-diff_fgetpos(file_t *f, fpos_t *pos)
-{
-	if (f->mapped) {
-		pos->_pos = f->curpos;
-		return 0;
-	} else {
-		return fgetpos(f->fp, pos);
-	}
-}
-
-static int
-diff_fsetpos(file_t *f, const fpos_t *pos)
-{
-	if (f->mapped) {
-		f->curpos = pos->_pos;
-		return 0;
-	} else {
-		return fsetpos(f->fp, pos);
-	}
-}
-
 /*
  * Check to see if the given files differ.
  * Returns 0 if they are the same, 1 if different, and -1 on error.
@@ -771,7 +753,7 @@ check(diff_t *diff, stone_t *s, file_t *
 {
 	int	i, j, jackpot, c, d, spacecount;
 	int64_t	ct[2];
-	fpos_t position;
+	off_t	position;
 		
 	diff_fseek(&f[0], 0, SEEK_SET);
 	diff_fseek(&f[1], 0, SEEK_SET);
@@ -850,14 +832,14 @@ check(diff_t *diff, stone_t *s, file_t *
 							 * Checks if file1 has 8 consecutive spaces, which is 
 							 * equal to 1 tab.
 							 */
-							diff_fgetpos(&f[0], &position);
+							position = diff_ftell(&f[0]);
 							for (spacecount = 1; spacecount <= 8; spacecount++) {
 								c = diff_getc(diff, &f[0]);
 								if (c != ' ') {
 									break;
 								}
 							}
-							diff_fsetpos(&f[0], &position);
+							diff_fseek(&f[0], position, SEEK_SET);
 							while (c == ' ' && spacecount == 9) {
 								c = diff_getc(diff, &f[0]);
 								ct[0]++;
@@ -868,14 +850,14 @@ check(diff_t *diff, stone_t *s, file_t *
 							 * Checks if file2 has 8 consecutive spaces, which is 
 							 * equal to 1 tab.
 							 */
-							diff_fgetpos(&f[1], &position);
+							position = diff_ftell(&f[1]);
 							for (spacecount = 1; spacecount <= 8; spacecount++) {
 								d = diff_getc(diff, &f[1]);
 								if (d != ' ') {
 									break;
 								}
 							}
-							diff_fsetpos(&f[1], &position);
+							diff_fseek(&f[1], position, SEEK_SET);
 							while (d == ' ' && spacecount == 9) {
 								d = diff_getc(diff, &f[1]);
 								ct[1]++;

Reply via email to