History log of /openbsd-current/usr.bin/locate/locate/util.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.17 28-Apr-2023 tb

Make LLVM 15 happier by changing from K&R to ANSI prototypes


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.16 17-Jan-2019 tedu

delete some historic $Id that have been chewed on by cvs
ok millert mpi


# 1.15 14-Jan-2019 schwarze

Untimely spring cleaning:
* Garbage collect useless hand-rolled lookup tables.
* Merge one-line helper functions into callers.
* Garbage collect obfuscating macros.
* Fix one format string error (%d used for u_int).
* Garbage collect setlocale(3) and <locale.h>.
* Garbage collect several unused constants.
* Minus 45 LOC, no functional change.

As noticed by tedu@, the lookup table "table" was used uninitialized.
But since it was only used as a pre-matching optimization and the real
string comparison is done further down the line, that bug probably did
not cause wrong results but merely ruined -i performance.

Code review triggered by a naive question from Jan Stary.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.14 01-Sep-2016 tedu

keep the code that endian swaps, but remove the explanation that it's
for converting between freebsd and sunos.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 16-Nov-2014 tedu

correct type in sizeof by switching to sizeof(*ptr). (harmless)
from Nicolas Bedos


# 1.11 08-Oct-2014 doug

userland reallocarray audit.

Replace malloc() and realloc() calls that may have integer overflow in the
multiplication of the size argument with reallocarray().

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.9 08-Nov-2003 jmc

typos from Jonathon Gray;


# 1.8 29-Sep-2003 deraadt

realloc fix; ok henning cloder


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 24-Jun-2002 naddy

prevent potential unaligned access error; ok espie@, pval@


Revision tags: OPENBSD_3_1_BASE
# 1.5 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.4 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.3 17-Jan-1997 millert

r?index -> strr?chr


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type


# 1.16 17-Jan-2019 tedu

delete some historic $Id that have been chewed on by cvs
ok millert mpi


# 1.15 14-Jan-2019 schwarze

Untimely spring cleaning:
* Garbage collect useless hand-rolled lookup tables.
* Merge one-line helper functions into callers.
* Garbage collect obfuscating macros.
* Fix one format string error (%d used for u_int).
* Garbage collect setlocale(3) and <locale.h>.
* Garbage collect several unused constants.
* Minus 45 LOC, no functional change.

As noticed by tedu@, the lookup table "table" was used uninitialized.
But since it was only used as a pre-matching optimization and the real
string comparison is done further down the line, that bug probably did
not cause wrong results but merely ruined -i performance.

Code review triggered by a naive question from Jan Stary.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.14 01-Sep-2016 tedu

keep the code that endian swaps, but remove the explanation that it's
for converting between freebsd and sunos.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 16-Nov-2014 tedu

correct type in sizeof by switching to sizeof(*ptr). (harmless)
from Nicolas Bedos


# 1.11 08-Oct-2014 doug

userland reallocarray audit.

Replace malloc() and realloc() calls that may have integer overflow in the
multiplication of the size argument with reallocarray().

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.9 08-Nov-2003 jmc

typos from Jonathon Gray;


# 1.8 29-Sep-2003 deraadt

realloc fix; ok henning cloder


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 24-Jun-2002 naddy

prevent potential unaligned access error; ok espie@, pval@


Revision tags: OPENBSD_3_1_BASE
# 1.5 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.4 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.3 17-Jan-1997 millert

r?index -> strr?chr


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type


# 1.15 14-Jan-2019 schwarze

Untimely spring cleaning:
* Garbage collect useless hand-rolled lookup tables.
* Merge one-line helper functions into callers.
* Garbage collect obfuscating macros.
* Fix one format string error (%d used for u_int).
* Garbage collect setlocale(3) and <locale.h>.
* Garbage collect several unused constants.
* Minus 45 LOC, no functional change.

As noticed by tedu@, the lookup table "table" was used uninitialized.
But since it was only used as a pre-matching optimization and the real
string comparison is done further down the line, that bug probably did
not cause wrong results but merely ruined -i performance.

Code review triggered by a naive question from Jan Stary.
OK deraadt@ tedu@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.14 01-Sep-2016 tedu

keep the code that endian swaps, but remove the explanation that it's
for converting between freebsd and sunos.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 16-Nov-2014 tedu

correct type in sizeof by switching to sizeof(*ptr). (harmless)
from Nicolas Bedos


# 1.11 08-Oct-2014 doug

userland reallocarray audit.

Replace malloc() and realloc() calls that may have integer overflow in the
multiplication of the size argument with reallocarray().

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.9 08-Nov-2003 jmc

typos from Jonathon Gray;


# 1.8 29-Sep-2003 deraadt

realloc fix; ok henning cloder


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 24-Jun-2002 naddy

prevent potential unaligned access error; ok espie@, pval@


Revision tags: OPENBSD_3_1_BASE
# 1.5 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.4 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.3 17-Jan-1997 millert

r?index -> strr?chr


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.14 01-Sep-2016 tedu

keep the code that endian swaps, but remove the explanation that it's
for converting between freebsd and sunos.


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.13 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.12 16-Nov-2014 tedu

correct type in sizeof by switching to sizeof(*ptr). (harmless)
from Nicolas Bedos


# 1.11 08-Oct-2014 doug

userland reallocarray audit.

Replace malloc() and realloc() calls that may have integer overflow in the
multiplication of the size argument with reallocarray().

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.10 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.9 08-Nov-2003 jmc

typos from Jonathon Gray;


# 1.8 29-Sep-2003 deraadt

realloc fix; ok henning cloder


Revision tags: OPENBSD_3_4_BASE
# 1.7 03-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.6 24-Jun-2002 naddy

prevent potential unaligned access error; ok espie@, pval@


Revision tags: OPENBSD_3_1_BASE
# 1.5 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.4 19-Nov-2001 mpech

kill more registers

millert@ ok


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.3 17-Jan-1997 millert

r?index -> strr?chr


# 1.2 10-Oct-1996 michaels

Fix searching for shell quoting characters. From wosch@freebsd.


Revision tags: OPENBSD_2_0_BASE
# 1.1 15-Sep-1996 michaels

Blind update of wosch@FreeBSD's code:

optimized search algorithm
faster IO due mmap(2) [-m | -s]
better error check for damaged databases
support for databases in network byte order (SunOS/sparc)
optional case insensitve search [-i]
optional multiple databases
optional multiple pattern
new enviroment variable LOCATE_PATH for database(s)
[-S] print some statistic about the database
[-l number] limit output to number file names
[-c] suppress normal output; instead print a count of matching file names
fix prototypes/forward declarations/return type