0006-Initialize-pseudo-random-number-generator-with-curre.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From: Nils Werner <wernerns@iis.fraunhofer.de>
  2. Date: Thu, 24 Jan 2013 18:44:03 +0000
  3. Subject: Initialize pseudo random number generator with current time or
  4. optional command line parameter
  5. ---
  6. xsltproc/xsltproc.c | 15 +++++++++++++++
  7. 1 file changed, 15 insertions(+)
  8. diff --git a/xsltproc/xsltproc.c b/xsltproc/xsltproc.c
  9. index 33beddf..7d1fe61 100644
  10. --- a/xsltproc/xsltproc.c
  11. +++ b/xsltproc/xsltproc.c
  12. @@ -514,6 +514,7 @@ static void usage(const char *name) {
  13. printf("\t--maxdepth val : increase the maximum depth (default %d)\n", xsltMaxDepth);
  14. printf("\t--maxvars val : increase the maximum variables (default %d)\n", xsltMaxVars);
  15. printf("\t--maxparserdepth val : increase the maximum parser depth\n");
  16. + printf("\t--seed-rand val : initialize pseudo random number generator with specific seed\n");
  17. #ifdef LIBXML_HTML_ENABLED
  18. printf("\t--html: the input document is(are) an HTML file(s)\n");
  19. #endif
  20. @@ -556,6 +557,7 @@ main(int argc, char **argv)
  21. return (1);
  22. }
  23. + srand(time(NULL));
  24. xmlInitMemory();
  25. LIBXML_TEST_VERSION
  26. @@ -750,6 +752,15 @@ main(int argc, char **argv)
  27. if (value > 0)
  28. xmlParserMaxDepth = value;
  29. }
  30. + } else if ((!strcmp(argv[i], "-seed-rand")) ||
  31. + (!strcmp(argv[i], "--seed-rand"))) {
  32. + int value;
  33. +
  34. + i++;
  35. + if (sscanf(argv[i], "%d", &value) == 1) {
  36. + if (value > 0)
  37. + srand(value);
  38. + }
  39. } else if ((!strcmp(argv[i],"-dumpextensions"))||
  40. (!strcmp(argv[i],"--dumpextensions"))) {
  41. dumpextensions++;
  42. @@ -786,6 +797,10 @@ main(int argc, char **argv)
  43. (!strcmp(argv[i], "--maxparserdepth"))) {
  44. i++;
  45. continue;
  46. + } else if ((!strcmp(argv[i], "-seed-rand")) ||
  47. + (!strcmp(argv[i], "--seed-rand"))) {
  48. + i++;
  49. + continue;
  50. } else if ((!strcmp(argv[i], "-o")) ||
  51. (!strcmp(argv[i], "-output")) ||
  52. (!strcmp(argv[i], "--output"))) {