[xml] 2.4.12: xmllint output file diffs



This message is in MIME format which your mailer apparently does not support.
You either require a newer version of your software which supports MIME, or
a separate MIME decoding utility.  Alternatively, ask the sender of this
message to resend it in a different format.

--1712709100--1844459861--678994017
Content-Type: text/plain; charset=us-ascii

Hiya,

I have added (simple) support for specifying the output file to write to
with xmllint. I believe I've caught all the cases where output is written
and generated a valid diff that will function on unix systems.

Additions:

   --output <file>
or -o <file>
      Write output to file, rather than to stdout

The variable 'output' is NULL if output is to be send to stdout, or a
filename otherwise.

In addition, if HAVE_ZLIB_H is unset (no zlib support present) xmllint does
not describe the -compress option in its help summary, nor will it be
processed as a command line option.

This patch should be applied to the release 2.4.12 xmllint, rather than
a version which has had the generic timing changes which I posted a while
back made. I'm not sure if you wanted to take the timing changes, so felt
it wises to do the diff from the last release, rather than the current
version.

-- 
Gerph {djf0-.3w6e2w2.226,6q6w2q2,2.3,2m4}
URL: http://www.movspclr.co.uk/
... Eyes to the heavens, screaming at the sky;
    Trying to send you messages, but choking on goodbye.

--1712709100--1844459861--678994017
Content-Type: text/plain; charset=iso-8859-1; name="xmllint.diff"
Content-Disposition: attachment; filename="xmllint.diff"
Content-Transfer-Encoding: quoted-printable

*** xmllint/orig        Wed Dec  5 03:35:06 2001
--- xmllint/riscos      Mon Dec 17 09:56:19 2001
***************
*** 20,26 ****
--- 20,31 ----
  #include <sys/time.h>
  #endif /* _MSC_VER */
  #else /* _WIN32 */
+ #ifdef HAVE_SYS_TIME_H
  #include <sys/time.h>
+ #endif
+ #ifdef HAVE_TIME_H
+ #include <time.h>
+ #endif
  #endif /* _WIN32 */
 =20
 =20
***************
*** 110,121 ****
  static int progresult =3D 0;
  static int timing =3D 0;
  static int generate =3D 0;
- static struct timeval begin, end;
  #ifdef LIBXML_CATALOG_ENABLED
  static int catalogs =3D 0;
  static int nocatalogs =3D 0;
  #endif
 =20
  /**********************************************************************=
**
   *                                                                    *
   *                    HTML ouput                                      *
--- 115,220 ----
  static int progresult =3D 0;
  static int timing =3D 0;
  static int generate =3D 0;
  #ifdef LIBXML_CATALOG_ENABLED
  static int catalogs =3D 0;
  static int nocatalogs =3D 0;
  #endif
 =20
+ /*
+  * Internal timing routines to remove the necessity to have unix-specif=
ic
+  * function calls
+  */
+=20
+ #if defined(HAVE_GETTIMEOFDAY)
+ static struct timeval begin, end;
+ /*
+  * startTimer: call where you want to start timing
+  */
+ static void startTimer(void)
+ {
+     gettimeofday(&begin,NULL);
+ }
+ /*
+  * endTimer: call where you want to stop timing and to print out a
+  *           message about the timing performed; format is a printf
+  *           type argument
+  */
+ static void endTimer(const char *format, ...)
+ {
+     long msec;
+     va_list ap;
+=20
+     gettimeofday(&end, NULL);
+     msec =3D end.tv_sec - begin.tv_sec;
+     msec *=3D 1000;
+     msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
+=20
+ #ifndef HAVE_STDARG_H
+ #error "endTimer required stdarg functions"
+ #endif
+     va_start(ap, format);
+     vfprintf(stderr,format,ap);
+     va_end(ap);
+=20
+     fprintf(stderr, " took %ld ms\n", msec);
+ }
+ #elif defined(HAVE_TIME_H)
+ /*
+  * No gettimeofday function, so we have to make do with calling clock.
+  * This is obviously less accurate, but there's little we can do about
+  * that.
+  */
+=20
+ static clock_t begin, end;
+ static void startTimer(void)
+ {
+     begin=3Dclock();
+ }
+ static void endTimer(char *format, ...)
+ {
+     long msec;
+     va_list ap;
+=20
+     end=3Dclock();
+     msec =3D ((end-begin) * 1000) / CLOCKS_PER_SEC;
+=20
+ #ifndef HAVE_STDARG_H
+ #error "endTimer required stdarg functions"
+ #endif
+     va_start(ap, format);
+     vfprintf(stderr,format,ap);
+     va_end(ap);
+     fprintf(stderr, " took %ld ms\n", msec);
+ }
+ #else
+ /*
+  * We don't have a gettimeofday or time.h, so we just don't do timing
+  */
+ static void startTimer(void)
+ {
+   /*
+    * Do nothing
+    */
+ }
+ static void endTimer(char *format, ...)
+ {
+   /*
+    * We cannot do anything because we don't have a timing function
+    */
+ #ifdef HAVE_STDARG_H
+     va_start(ap, format);
+     vfprintf(stderr,format,ap);
+     va_end(ap);
+     fprintf(stderr, " was not timed\n", msec);
+ #else
+   /* We don't have gettimeofday, time or stdarg.h, what crazy world is
+    * this ?!
+    */
+ #endif
+ }
+ #endif
+=20
+=20
  /**********************************************************************=
**
   *                                                                    *
   *                    HTML ouput                                      *
***************
*** 405,411 ****
      xmlDocPtr doc =3D NULL, tmp;
 =20
      if ((timing) && (!repeat))
!       gettimeofday(&begin, NULL);
     =20
 =20
      if (filename =3D=3D NULL) {
--- 504,510 ----
      xmlDocPtr doc =3D NULL, tmp;
 =20
      if ((timing) && (!repeat))
!       startTimer();
 =20
 =20
      if (filename =3D=3D NULL) {
***************
*** 591,617 ****
      }
 =20
      if ((timing) && (!repeat)) {
!       long msec;
!       gettimeofday(&end, NULL);
!       msec =3D end.tv_sec - begin.tv_sec;
!       msec *=3D 1000;
!       msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!       fprintf(stderr, "Parsing took %ld ms\n", msec);
      }
 =20
  #ifdef LIBXML_XINCLUDE_ENABLED
      if (xinclude) {
        if ((timing) && (!repeat)) {
!           gettimeofday(&begin, NULL);
        }
        xmlXIncludeProcess(doc);
        if ((timing) && (!repeat)) {
!           long msec;
!           gettimeofday(&end, NULL);
!           msec =3D end.tv_sec - begin.tv_sec;
!           msec *=3D 1000;
!           msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!           fprintf(stderr, "Xinclude processing took %ld ms\n", msec);
        }
      }
  #endif
--- 690,706 ----
      }
 =20
      if ((timing) && (!repeat)) {
!       endTimer("Parsing");
      }
 =20
  #ifdef LIBXML_XINCLUDE_ENABLED
      if (xinclude) {
        if ((timing) && (!repeat)) {
!           startTimer();
        }
        xmlXIncludeProcess(doc);
        if ((timing) && (!repeat)) {
!           endTimer("Xinclude processing");
        }
      }
  #endif
***************
*** 664,670 ****
        if (!debug) {
  #endif
            if ((timing) && (!repeat)) {
!               gettimeofday(&begin, NULL);
            }
  #ifdef HAVE_SYS_MMAN_H
            if (memory) {
--- 753,759 ----
        if (!debug) {
  #endif
            if ((timing) && (!repeat)) {
!               startTimer();
            }
  #ifdef HAVE_SYS_MMAN_H
            if (memory) {
***************
*** 706,717 ****
            else
                xmlDocDump(stdout, doc);
            if ((timing) && (!repeat)) {
!               long msec;
!               gettimeofday(&end, NULL);
!               msec =3D end.tv_sec - begin.tv_sec;
!               msec *=3D 1000;
!               msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!               fprintf(stderr, "Saving took %ld ms\n", msec);
            }
  #ifdef LIBXML_DEBUG_ENABLED
        } else {
--- 795,801 ----
            else
                xmlDocDump(stdout, doc);
            if ((timing) && (!repeat)) {
!               endTimer("Saving");
            }
  #ifdef LIBXML_DEBUG_ENABLED
        } else {
***************
*** 727,742 ****
        xmlDtdPtr dtd;
 =20
        if ((timing) && (!repeat)) {
!           gettimeofday(&begin, NULL);
        }
        dtd =3D xmlParseDTD(NULL, (const xmlChar *)dtdvalid);=20
        if ((timing) && (!repeat)) {
!           long msec;
!           gettimeofday(&end, NULL);
!           msec =3D end.tv_sec - begin.tv_sec;
!           msec *=3D 1000;
!           msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!           fprintf(stderr, "Parsing DTD took %ld ms\n", msec);
        }
        if (dtd =3D=3D NULL) {
            xmlGenericError(xmlGenericErrorContext,
--- 811,821 ----
        xmlDtdPtr dtd;
 =20
        if ((timing) && (!repeat)) {
!           startTimer();
        }
        dtd =3D xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
        if ((timing) && (!repeat)) {
!           endTimer("Parsing DTD");
        }
        if (dtd =3D=3D NULL) {
            xmlGenericError(xmlGenericErrorContext,
***************
*** 745,753 ****
        } else {
            xmlValidCtxt cvp;
            if ((timing) && (!repeat)) {
!               gettimeofday(&begin, NULL);
            }
!           cvp.userData =3D (void *) stderr;                                 =
                cvp.error    =3D (xmlValidityErrorFunc) fprintf;         =
                         cvp.warning  =3D (xmlValidityWarningFunc) fprint=
f;
            if (!xmlValidateDtd(&cvp, doc, dtd)) {
                xmlGenericError(xmlGenericErrorContext,
                        "Document %s does not validate against %s\n",
--- 824,834 ----
        } else {
            xmlValidCtxt cvp;
            if ((timing) && (!repeat)) {
!               startTimer();
            }
!           cvp.userData =3D (void *) stderr;
!           cvp.error    =3D (xmlValidityErrorFunc) fprintf;
!           cvp.warning  =3D (xmlValidityWarningFunc) fprintf;
            if (!xmlValidateDtd(&cvp, doc, dtd)) {
                xmlGenericError(xmlGenericErrorContext,
                        "Document %s does not validate against %s\n",
***************
*** 755,773 ****
                progresult =3D 3;
            }
            if ((timing) && (!repeat)) {
!               long msec;
!               gettimeofday(&end, NULL);
!               msec =3D end.tv_sec - begin.tv_sec;
!               msec *=3D 1000;
!               msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!               fprintf(stderr, "Validating against DTD took %ld ms\n", msec);
            }
            xmlFreeDtd(dtd);
        }
      } else if (postvalid) {
        xmlValidCtxt cvp;
        if ((timing) && (!repeat)) {
!           gettimeofday(&begin, NULL);
        }
        cvp.userData =3D (void *) stderr;
        cvp.error    =3D (xmlValidityErrorFunc) fprintf;
--- 836,849 ----
                progresult =3D 3;
            }
            if ((timing) && (!repeat)) {
!               endTimer("Validating against DTD");
            }
            xmlFreeDtd(dtd);
        }
      } else if (postvalid) {
        xmlValidCtxt cvp;
        if ((timing) && (!repeat)) {
!           startTimer();
        }
        cvp.userData =3D (void *) stderr;
        cvp.error    =3D (xmlValidityErrorFunc) fprintf;
***************
*** 778,789 ****
            progresult =3D 3;
        }
        if ((timing) && (!repeat)) {
!           long msec;
!           gettimeofday(&end, NULL);
!           msec =3D end.tv_sec - begin.tv_sec;
!           msec *=3D 1000;
!           msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!           fprintf(stderr, "Validating took %ld ms\n", msec);
        }
      }
 =20
--- 854,860 ----
            progresult =3D 3;
        }
        if ((timing) && (!repeat)) {
!           endTimer("Validating");
        }
      }
 =20
***************
*** 796,811 ****
       * free it.
       */
      if ((timing) && (!repeat)) {
!       gettimeofday(&begin, NULL);
      }
      xmlFreeDoc(doc);
      if ((timing) && (!repeat)) {
!       long msec;
!       gettimeofday(&end, NULL);
!       msec =3D end.tv_sec - begin.tv_sec;
!       msec *=3D 1000;
!       msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!       fprintf(stderr, "Freeing took %ld ms\n", msec);
      }
  }
 =20
--- 867,877 ----
       * free it.
       */
      if ((timing) && (!repeat)) {
!       startTimer();
      }
      xmlFreeDoc(doc);
      if ((timing) && (!repeat)) {
!       endTimer("Freeing");
      }
  }
 =20
***************
*** 1073,1079 ****
            continue;
          }
        if ((timing) && (repeat))
!           gettimeofday(&begin, NULL);
        /* Remember file names.  "-" means stding.  <sven zen org> */
        if ((argv[i][0] !=3D '-') || (strcmp(argv[i], "-") =3D=3D 0)) {
            if (repeat) {
--- 1139,1145 ----
            continue;
          }
        if ((timing) && (repeat))
!           startTimer();
        /* Remember file names.  "-" means stding.  <sven zen org> */
        if ((argv[i][0] !=3D '-') || (strcmp(argv[i], "-") =3D=3D 0)) {
            if (repeat) {
***************
*** 1083,1094 ****
                parseAndPrintFile(argv[i]);
            files ++;
            if ((timing) && (repeat)) {
!               long msec;
!               gettimeofday(&end, NULL);
!               msec =3D end.tv_sec - begin.tv_sec;
!               msec *=3D 1000;
!               msec +=3D (end.tv_usec - begin.tv_usec) / 1000;
!               fprintf(stderr, "100 iterations took %ld ms\n", msec);
            }
        }
      }
--- 1149,1155 ----
                parseAndPrintFile(argv[i]);
            files ++;
            if ((timing) && (repeat)) {
!               endTimer("100 iterations");
            }
        }
      }

--1712709100--1844459861--678994017--



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]