History log of /openbsd-current/usr.bin/rcs/diff.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.40 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 16-Oct-2016 okan

Quiet compiler warnings; as applied to usr.bin/cvs by millert@

ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.38 13-Jun-2015 nicm

Convert xfree to free. From Fritjof Bornebusch. ok deraadt


Revision tags: OPENBSD_5_7_BASE
# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.36 01-Dec-2014 deraadt

An internal function called xrealloc() is actually a fail-hard
reallocarray()... so rename it.


# 1.35 10-Oct-2014 otto

Zap some stored values never read; From Fritjof Bornebusch; ok nicm@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.34 16-May-2013 stsp

Switch rcsdiff(1) binary file detection from !(isprint() || isspace()) to
checking for embedded NULs, as was done for grep(1) and diff(1) some time ago.
Avoids problems with e.g. latin1-encoded files being treated as binary, since
isprint() uses only ASCII by default and rcsdiff(1) doesn't call setlocale().
ok sthen


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.33 20-Apr-2011 nicm

Remove some unneeded includes and dead code, from Michael W Bombardieri.

ok jasper xsa


# 1.32 01-Apr-2011 nicm

Move an isqrt() call outside a macro, from Michael W Bombardieri.

ok ray


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.31 23-Jul-2010 ray

Reduce variable/function name and whitespace differences between
cvs/rcs.

OK xsa zinovik


# 1.30 16-Jul-2010 ray

Combine two diff_output lines into one, from diff.

OK stsp xsa nicm


# 1.29 15-Jul-2010 ray

Die immediately if pread fails. It's a fatal error so treat it as
such. Besides, we weren't handling the NULL being returned.

From diff. Minor nit by nicm.

OK xsa stsp nicm


# 1.28 15-Jul-2010 ray

Use warnx instead of warn since errno wasn't set. From diff.

OK xsa stsp nicm


# 1.27 15-Jul-2010 ray

Sync with diff/diffreg.c r1.75:
Return -1 on error as advertised.
Handle case when only one stream failed.

OK xsa, stsp


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 07-Jun-2009 ray

More cvs/diff/rcs convergence:
1. Mostly variable/function renaming, SIZE_T_MAX->SIZE_MAX, and
spacing.
2. One strchr -> strncspn.
3. diff had a weird thing where it set file[12] = ofile[12] but
never updated file or ofile, then if file and ofile were different
it freed it. I removed it.

OK millert


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.25 11-Sep-2007 gilles

use strcspn to properly overwrite '\n' in fgets returned buffer

ok pyr@, ray@, millert@, moritz@, chl@


Revision tags: OPENBSD_4_2_BASE
# 1.24 03-Jul-2007 ray

Rename rcs_diffreg() to diffreg().

OK joris@


# 1.23 29-Jun-2007 ray

Sync cvs/rcs diff code.

OK joris and xsa.


# 1.22 28-Jun-2007 ray

diff(1) sync, mostly spacing and moving crap around, except:
- stone() and newcand() cannot return < 0, so don't check it.
- \r, \v, \f are also whitespace

OK joris


# 1.21 28-Jun-2007 ray

Some syncs with diff(1):
- prepare() only returns 0, so change it to void and remove code
that checks its return value.
- Rename diff_len[] to len[].
- Remove casts that made the code a no-op:
(size_t)filesize <= SIZE_MAX

OK xsa


# 1.20 30-May-2007 ray

Remove cand structure (but not its definition).


# 1.19 30-May-2007 ray

Remove unused struct diff_arg.


# 1.18 29-May-2007 ray

Get rid of another useless variable, another difference between our
diff code and diff(1).

OK niallo@


# 1.17 29-May-2007 ray

Since xrealloc dies on failure it is safe to directly assign to the
original pointer. Theo agrees, and so does the rest of the tree
(ssh, etc. all do this already).

Saves a bunch of variables and assignments.

OK niallo@


# 1.16 28-May-2007 ray

Some spacing syncs with diff(1).


# 1.15 28-May-2007 ray

"in formation" -> "information"

OK niallo@


# 1.14 28-May-2007 ray

Line up comments with the rest of the file, like in diff(1).


# 1.13 27-Mar-2007 xsa

sync with espie@'s latest change to diff(1).

from src/usr.bin/diff/diffreg.c rev 1.67:

improve -p for C++ code: classes definition often have
public:/protected:/private: at the start of line.
This lets the -p scanner just take note of the section and keep
looking for the actual class definition.

Also increase function name bufsize so it shows most of these pesky C++
decls...

OK niallo@ espie@.


Revision tags: OPENBSD_4_1_BASE
# 1.12 27-Feb-2007 xsa

As done in OpenCVS, general includes cleanup sweep. OK otto@.


# 1.11 22-Feb-2007 xsa

Fix const inconsistencies, void pointer artithmetic;
Based on diff from otto@ in OpenCVS. OK otto@.


# 1.10 27-Sep-2006 ray

Plug memory leak.

OK niallo@.


# 1.9 21-Sep-2006 millert

Add support to rcsdiff for all the other diff flags that
are pertinent to files (not directories) and that do not
conflict with rcsdiff-specific flags. OK xsa@


Revision tags: OPENBSD_4_0_BASE
# 1.8 14-Aug-2006 ray

files_differ() should return -1 on error, according to comments. Make
it so.

Add checks for all return values.

``put it in'' xsa@


# 1.7 27-Jul-2006 deraadt

spacing


# 1.6 11-May-2006 ray

Use fstat instead of stat, simplifie switch statement into if
statement, and remove __inline.

OK xsa@


# 1.5 10-May-2006 ray

Remove (size_t) casts on integer constants.

We should not cover up lint's shortcomings, especially if they no
longer exist.

``This is definately good.'' niallo@.


# 1.4 05-May-2006 xsa

- fix rcsdiff exit status on success/errors; now matches gnu/usr.bin/rcs.
- add DIAGNOSTICS section to rcsdiff.1 wrt exit codes.
ok ray@ and jmc@ for man page bits.


# 1.3 29-Apr-2006 ray

Check return values for all strlcpy, and strlcat calls.

OK xsa@ and probably others.


# 1.2 26-Apr-2006 xsa

err() cleanup;


# 1.1 26-Apr-2006 joris

fork our code we shared between openrcs/cvs into the openrcs dir.

this was starting to become inhuman to maintain without
ugly ugly hacks in the shared code, and it will be easier
to make specific changes for openrcs without touching the
soon-to-be-replaced opencvs code.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 16-Oct-2016 okan

Quiet compiler warnings; as applied to usr.bin/cvs by millert@

ok millert@


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.38 13-Jun-2015 nicm

Convert xfree to free. From Fritjof Bornebusch. ok deraadt


Revision tags: OPENBSD_5_7_BASE
# 1.37 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.36 01-Dec-2014 deraadt

An internal function called xrealloc() is actually a fail-hard
reallocarray()... so rename it.


# 1.35 10-Oct-2014 otto

Zap some stored values never read; From Fritjof Bornebusch; ok nicm@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.34 16-May-2013 stsp

Switch rcsdiff(1) binary file detection from !(isprint() || isspace()) to
checking for embedded NULs, as was done for grep(1) and diff(1) some time ago.
Avoids problems with e.g. latin1-encoded files being treated as binary, since
isprint() uses only ASCII by default and rcsdiff(1) doesn't call setlocale().
ok sthen


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.33 20-Apr-2011 nicm

Remove some unneeded includes and dead code, from Michael W Bombardieri.

ok jasper xsa


# 1.32 01-Apr-2011 nicm

Move an isqrt() call outside a macro, from Michael W Bombardieri.

ok ray


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.31 23-Jul-2010 ray

Reduce variable/function name and whitespace differences between
cvs/rcs.

OK xsa zinovik


# 1.30 16-Jul-2010 ray

Combine two diff_output lines into one, from diff.

OK stsp xsa nicm


# 1.29 15-Jul-2010 ray

Die immediately if pread fails. It's a fatal error so treat it as
such. Besides, we weren't handling the NULL being returned.

From diff. Minor nit by nicm.

OK xsa stsp nicm


# 1.28 15-Jul-2010 ray

Use warnx instead of warn since errno wasn't set. From diff.

OK xsa stsp nicm


# 1.27 15-Jul-2010 ray

Sync with diff/diffreg.c r1.75:
Return -1 on error as advertised.
Handle case when only one stream failed.

OK xsa, stsp


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.26 07-Jun-2009 ray

More cvs/diff/rcs convergence:
1. Mostly variable/function renaming, SIZE_T_MAX->SIZE_MAX, and
spacing.
2. One strchr -> strncspn.
3. diff had a weird thing where it set file[12] = ofile[12] but
never updated file or ofile, then if file and ofile were different
it freed it. I removed it.

OK millert


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.25 11-Sep-2007 gilles

use strcspn to properly overwrite '\n' in fgets returned buffer

ok pyr@, ray@, millert@, moritz@, chl@


Revision tags: OPENBSD_4_2_BASE
# 1.24 03-Jul-2007 ray

Rename rcs_diffreg() to diffreg().

OK joris@


# 1.23 29-Jun-2007 ray

Sync cvs/rcs diff code.

OK joris and xsa.


# 1.22 28-Jun-2007 ray

diff(1) sync, mostly spacing and moving crap around, except:
- stone() and newcand() cannot return < 0, so don't check it.
- \r, \v, \f are also whitespace

OK joris


# 1.21 28-Jun-2007 ray

Some syncs with diff(1):
- prepare() only returns 0, so change it to void and remove code
that checks its return value.
- Rename diff_len[] to len[].
- Remove casts that made the code a no-op:
(size_t)filesize <= SIZE_MAX

OK xsa


# 1.20 30-May-2007 ray

Remove cand structure (but not its definition).


# 1.19 30-May-2007 ray

Remove unused struct diff_arg.


# 1.18 29-May-2007 ray

Get rid of another useless variable, another difference between our
diff code and diff(1).

OK niallo@


# 1.17 29-May-2007 ray

Since xrealloc dies on failure it is safe to directly assign to the
original pointer. Theo agrees, and so does the rest of the tree
(ssh, etc. all do this already).

Saves a bunch of variables and assignments.

OK niallo@


# 1.16 28-May-2007 ray

Some spacing syncs with diff(1).


# 1.15 28-May-2007 ray

"in formation" -> "information"

OK niallo@


# 1.14 28-May-2007 ray

Line up comments with the rest of the file, like in diff(1).


# 1.13 27-Mar-2007 xsa

sync with espie@'s latest change to diff(1).

from src/usr.bin/diff/diffreg.c rev 1.67:

improve -p for C++ code: classes definition often have
public:/protected:/private: at the start of line.
This lets the -p scanner just take note of the section and keep
looking for the actual class definition.

Also increase function name bufsize so it shows most of these pesky C++
decls...

OK niallo@ espie@.


Revision tags: OPENBSD_4_1_BASE
# 1.12 27-Feb-2007 xsa

As done in OpenCVS, general includes cleanup sweep. OK otto@.


# 1.11 22-Feb-2007 xsa

Fix const inconsistencies, void pointer artithmetic;
Based on diff from otto@ in OpenCVS. OK otto@.


# 1.10 27-Sep-2006 ray

Plug memory leak.

OK niallo@.


# 1.9 21-Sep-2006 millert

Add support to rcsdiff for all the other diff flags that
are pertinent to files (not directories) and that do not
conflict with rcsdiff-specific flags. OK xsa@


Revision tags: OPENBSD_4_0_BASE
# 1.8 14-Aug-2006 ray

files_differ() should return -1 on error, according to comments. Make
it so.

Add checks for all return values.

``put it in'' xsa@


# 1.7 27-Jul-2006 deraadt

spacing


# 1.6 11-May-2006 ray

Use fstat instead of stat, simplifie switch statement into if
statement, and remove __inline.

OK xsa@


# 1.5 10-May-2006 ray

Remove (size_t) casts on integer constants.

We should not cover up lint's shortcomings, especially if they no
longer exist.

``This is definately good.'' niallo@.


# 1.4 05-May-2006 xsa

- fix rcsdiff exit status on success/errors; now matches gnu/usr.bin/rcs.
- add DIAGNOSTICS section to rcsdiff.1 wrt exit codes.
ok ray@ and jmc@ for man page bits.


# 1.3 29-Apr-2006 ray

Check return values for all strlcpy, and strlcat calls.

OK xsa@ and probably others.


# 1.2 26-Apr-2006 xsa

err() cleanup;


# 1.1 26-Apr-2006 joris

fork our code we shared between openrcs/cvs into the openrcs dir.

this was starting to become inhuman to maintain without
ugly ugly hacks in the shared code, and it will be easier
to make specific changes for openrcs without touching the
soon-to-be-replaced opencvs code.