diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2014-12-06 18:38:47 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2014-12-06 18:38:47 +0000 |
commit | c5d575404174dc5d2a55bcd2fb75948b117c798e (patch) | |
tree | 735361cc366bbc9255a8104e9bc5de26a4ed508f | |
parent | 58355c0dc3976512675b6d463662ff745e2854ae (diff) | |
download | netpbm-mirror-c5d575404174dc5d2a55bcd2fb75948b117c798e.tar.gz netpbm-mirror-c5d575404174dc5d2a55bcd2fb75948b117c798e.tar.xz netpbm-mirror-c5d575404174dc5d2a55bcd2fb75948b117c798e.zip |
Add -verbose
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2334 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | doc/HISTORY | 8 | ||||
-rw-r--r-- | generator/pamcrater.c | 21 |
2 files changed, 19 insertions, 10 deletions
diff --git a/doc/HISTORY b/doc/HISTORY index 3981cc2b..a86b5afa 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -6,14 +6,13 @@ CHANGE HISTORY not yet BJH Release 10.69.00 + pamcrater: Add -verbose. + ppmtoarbtxt: Fail if a #() escape sequence runs off end of file or is too long to process; before, the program would treat the text from # to EOF or where the buffer filled up as literal text, even ignoring any #() within. - ppmtoarbtxt: Fix some undefined behavior when program limits - are exceeded (i.e. buffer overruns). - NetBSD: show actual numbers in messages instead of "f" or no information, by using NetBSD's vasprintf. @@ -24,6 +23,9 @@ not yet BJH Release 10.69.00 anytopnm: convert all images in a multi-image GIF instead of just the first. + ppmtoarbtxt: Fix some undefined behavior when program limits + are exceeded (i.e. buffer overruns). + pambackground: fix bug: segfault or incorrect results in most cases. Thanks Ludolf Holzheid (ludolf.holzheid@gmx.de). Introduced in Netpbm 10.37 (December 2006). diff --git a/generator/pamcrater.c b/generator/pamcrater.c index 0da4e9fb..3acc4966 100644 --- a/generator/pamcrater.c +++ b/generator/pamcrater.c @@ -62,6 +62,7 @@ struct CmdlineInfo { unsigned int width; unsigned int randomseedSpec; unsigned int randomseed; + unsigned int verbose; unsigned int test; unsigned int radius; int offset; @@ -95,6 +96,8 @@ parseCommandLine(int argc, const char ** const argv, &widthSpec, 0); OPTENT3(0, "randomseed", OPT_UINT, &cmdlineP->randomseed, &cmdlineP->randomseedSpec, 0); + OPTENT3(0, "verbose", OPT_FLAG, NULL, + &cmdlineP->verbose, 0); OPTENT3(0, "test", OPT_FLAG, NULL, &cmdlineP->test, 0); OPTENT3(0, "radius", OPT_UINT, &cmdlineP->radius, @@ -158,9 +161,6 @@ parseCommandLine(int argc, const char ** const argv, } -/* Definitions for obtaining random numbers. */ - -/* Display parameters */ static double const arand = 32767.0; /* Random number parameters */ static double const CdepthPower = 1.5; /* Crater depth power factor */ @@ -170,7 +170,9 @@ static double const DepthBias2 = 0.5; /* Square of depth bias */ static double const cast(double const high) { - +/*---------------------------------------------------------------------------- + A random number in the range [0, 'high']. +-----------------------------------------------------------------------------*/ return high * ((rand() & 0x7FFF) / arand); } @@ -378,7 +380,12 @@ plopCrater(struct pam * const pamP, tuple ** const terrain, int const cx, int const cy, - double const radius) { + double const radius, + bool const verbose) { + + if (verbose && pm_have_float_format()) + pm_message("Plopping crater at (%4d, %4d) with radius %g", + cx, cy, radius); if (radius < 3) smallCrater (pamP, terrain, cx, cy, radius); @@ -440,7 +447,7 @@ genCraters(struct CmdlineInfo const cmdline) { plopCrater(&pam, terrain, pam.width/2 + cmdline.offset, pam.height/2 + cmdline.offset, - (double) cmdline.radius); + (double) cmdline.radius, cmdline.verbose); else { unsigned int const ncraters = cmdline.number; /* num of craters */ unsigned int l; @@ -458,7 +465,7 @@ genCraters(struct CmdlineInfo const cmdline) { */ double const radius = sqrt(1 / (M_PI * (1 - cast(0.9999)))); - plopCrater(&pam, terrain, cx, cy, radius); + plopCrater(&pam, terrain, cx, cy, radius, cmdline.verbose); if (((l + 1) % 100000) == 0) pm_message("%u craters generated of %u (%u%% done)", |