1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- From: Nils Werner <wernerns@iis.fraunhofer.de>
- Date: Thu, 24 Jan 2013 18:44:03 +0000
- Subject: Initialize pseudo random number generator with current time or
- optional command line parameter
- ---
- xsltproc/xsltproc.c | 15 +++++++++++++++
- 1 file changed, 15 insertions(+)
- diff --git a/xsltproc/xsltproc.c b/xsltproc/xsltproc.c
- index 33beddf..7d1fe61 100644
- --- a/xsltproc/xsltproc.c
- +++ b/xsltproc/xsltproc.c
- @@ -514,6 +514,7 @@ static void usage(const char *name) {
- printf("\t--maxdepth val : increase the maximum depth (default %d)\n", xsltMaxDepth);
- printf("\t--maxvars val : increase the maximum variables (default %d)\n", xsltMaxVars);
- printf("\t--maxparserdepth val : increase the maximum parser depth\n");
- + printf("\t--seed-rand val : initialize pseudo random number generator with specific seed\n");
- #ifdef LIBXML_HTML_ENABLED
- printf("\t--html: the input document is(are) an HTML file(s)\n");
- #endif
- @@ -556,6 +557,7 @@ main(int argc, char **argv)
- return (1);
- }
-
- + srand(time(NULL));
- xmlInitMemory();
-
- LIBXML_TEST_VERSION
- @@ -750,6 +752,15 @@ main(int argc, char **argv)
- if (value > 0)
- xmlParserMaxDepth = value;
- }
- + } else if ((!strcmp(argv[i], "-seed-rand")) ||
- + (!strcmp(argv[i], "--seed-rand"))) {
- + int value;
- +
- + i++;
- + if (sscanf(argv[i], "%d", &value) == 1) {
- + if (value > 0)
- + srand(value);
- + }
- } else if ((!strcmp(argv[i],"-dumpextensions"))||
- (!strcmp(argv[i],"--dumpextensions"))) {
- dumpextensions++;
- @@ -786,6 +797,10 @@ main(int argc, char **argv)
- (!strcmp(argv[i], "--maxparserdepth"))) {
- i++;
- continue;
- + } else if ((!strcmp(argv[i], "-seed-rand")) ||
- + (!strcmp(argv[i], "--seed-rand"))) {
- + i++;
- + continue;
- } else if ((!strcmp(argv[i], "-o")) ||
- (!strcmp(argv[i], "-output")) ||
- (!strcmp(argv[i], "--output"))) {
|