History log of /openbsd-current/games/factor/factor.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.30 01-Sep-2016 tb

In 32 bits sqrt(val) + 1 can overflow, so some big primes still
aren't recognized as such, for example 18446744073709551577 given
in the commit message of factor.c r1.7 from NetBSD. Move the
return type of usqrt() from u_int32_t to u_int64_t.

ok guenther, tom, otto


# 1.29 14-Aug-2016 guenther

Convert remaining calls to strtoq/strtouq in base with strtoll/strtoull.
Fix a type mismatch in ftp's "page" command and could make transfers restart
at the wrong position.

ok and a ull->ll tweak from natano@, ok tedu@


Revision tags: OPENBSD_6_0_BASE
# 1.28 11-Jul-2016 tb

Instead of using the floating point square root, use an integer version
of the Newton method from ping.c. Fixes a rounding issue that caused
failure to factor numbers close to 2^64, e.g. 18446744030759878681.
While there, fix an off by one error that caused 4295360521 to be
reported as a prime. Issues reported by Paul Stoeber and Michael Bozon.

ok tedu, deraadt


# 1.27 07-Mar-2016 mestre

- General changes:
- Remove -? from getopt(3) options, but still keep (or add) -h where applicable
- Replace hardcoded program strings by getprogname(3)

- Specific changes:
- atc(6): this used -? and -u for usage(), remove both from game and manpage
- bcd(6): use __progname instead of getprogname(3), no need to include stdlib.h
- hunt(6): replace fputs(3) by fprintf(3)

OK tb@ after his suggestions


Revision tags: OPENBSD_5_9_BASE
# 1.26 07-Jan-2016 tb

Some basic code maintenance in games/

- in main() replace exit with return
- drop some /* NOTREACHED */ lint comments along the way.
- make more use of standard CFLAGS, esp. -Wimplicit-function-declaration
- add and sort some headers when needed
- add straightforward pledges to some programs used at compile time

discussed with and ok mestre@


# 1.25 04-Jan-2016 mestre

More headers removal and sorted the remaining alphabetically.

Most noticeable that were removed are sys/types.h which will be included from
stdlib.h and in turn also brings along sys/cdefs.h. The other one is limits.h
that was used with the old idiom (denom * random() / LONG_MAX), although it was
only removed were applicable (some files still need that header).

OK tb@


# 1.24 30-Dec-2015 tb

Michal Mazurek pointed out on tech@ that the factor.6 manual needs a bit
of clarification. Thus, express the description both more concisely and
more precisely. Drop details about spaces in the output formatting.
While there, update the corresponding comment in the source code.

With input from jmc@ and mestre@; detailed discussion with sobrado@.

ok sobrado@


# 1.23 25-Dec-2015 mestre

Declare usage() functions as __dead void, if they don't return, on games section.

Found another one in arithmetic(6) which also didn't return, and removed a function from number(6) which is not used anymore.

OK tb@


# 1.22 24-Oct-2015 mmcc

Cast isblank()'s argument to unsigned char.

ok guenther@


# 1.21 14-Oct-2015 doug

Pledge "stdio" for simple games.

ok semarie@


# 1.20 07-Sep-2015 tedu

cosmetic fixes


Revision tags: 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 OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.18 17-Mar-2008 sobrado

synchronization between usage and synopsis; add some missing "usage:"'s

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.17 06-Sep-2007 chl

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

ok moritz@ ray@


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.16 12-Mar-2006 deraadt

exit code 1 on usage; adobriyan@gmail


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.15 09-Jul-2004 deraadt

ansi; khalek@linuxgamers.net


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.14 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.13 31-May-2002 pjanzen

No dm -> no need to revoke setegid.


Revision tags: OPENBSD_3_1_BASE
# 1.12 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.11 24-Oct-2001 deraadt

typo; ericyu@mail2000.com.tw


Revision tags: OPENBSD_3_0_BASE
# 1.10 19-Aug-2001 pjanzen

If primes(6) will generate 32-bit primes, factor should factor 64-bit numbers.


# 1.9 19-Aug-2001 pjanzen

Use u_int32_t rather than unsigned long, both for platform invariance and
because the primes generation table really depends on there not being more
than 32 bits.


# 1.8 19-Aug-2001 pjanzen

remove extraneous newline from error output; PR 2014 and patch from
Tim J. Robbins <tim@robbins.dropbear.id.au>, with one line added so
that trailing whitespace doesn't make a number seem badly formatted.


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.7 26-Sep-1999 pjanzen

Correct documentation: rogoyski@cs.utexas.edu in PR 927.


# 1.6 25-Sep-1999 pjanzen

Tidying and minor changes from or based on jsm28@cam.ac.uk's work for the
Linux bsd-games package and NetBSD. Mainly using 'const'.


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.5 19-Aug-1998 pjanzen

tags, formatting, ANSI-fication, prototypes, de-typos, and the occasional
initialization, removal of unused variable, or other minor fix. Most
changes are from or inspired by NetBSD.


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.4 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.3 22-Dec-1996 deraadt

proper gid revoke


# 1.2 19-Dec-1996 deraadt

setgid games, not setuid games. closes a neat set of holes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision