I found myself rewriting the ./src/tools/find_gt_lt script in Perl
this evening, since the existing script was quite broken (the main
problem is it's not capable of understanding CDATA or sgml comment
sections, and hence produces a bunch of noise).

The rewritten version picked up a few stylistic inconsistencies in the
SGML, such as:
 * breaking the trailing '>' of an SGML marker across lines. AFAIK
this is legal, but is a bit inconsistent and just confuses simplistic
tools like find_gt_lt
 * using single quotes instead of double quotes to surround a node
attribute, as in <orderedlist numeration='loweralpha'>

as well as seemingly-invalid SGML, such as using '>' unescaped inside
normal SGML entries.

I've attached a patch to fix these problems. I can send in the new
version of find_gt_lt if these changes prove useful.

Josh
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 89b531f..f026c7b 100644
*** a/doc/src/sgml/datatype.sgml
--- b/doc/src/sgml/datatype.sgml
*************** SELECT * FROM person WHERE current_mood
*** 2951,2964 ****
  <programlisting>
  INSERT INTO person VALUES ('Larry', 'sad');
  INSERT INTO person VALUES ('Curly', 'ok');
! SELECT * FROM person WHERE current_mood > 'sad';
   name  | current_mood 
  -------+--------------
   Moe   | happy
   Curly | ok
  (2 rows)
  
! SELECT * FROM person WHERE current_mood > 'sad' ORDER BY current_mood;
   name  | current_mood 
  -------+--------------
   Curly | ok
--- 2951,2964 ----
  <programlisting>
  INSERT INTO person VALUES ('Larry', 'sad');
  INSERT INTO person VALUES ('Curly', 'ok');
! SELECT * FROM person WHERE current_mood &gt; 'sad';
   name  | current_mood 
  -------+--------------
   Moe   | happy
   Curly | ok
  (2 rows)
  
! SELECT * FROM person WHERE current_mood &gt; 'sad' ORDER BY current_mood;
   name  | current_mood 
  -------+--------------
   Curly | ok
diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index 8470122..895403a 100644
*** a/doc/src/sgml/ecpg.sgml
--- b/doc/src/sgml/ecpg.sgml
*************** CREATE TABLE t3 (
*** 1416,1422 ****
      ii integer[]
  );
  
! testdb=> SELECT * FROM t3;
       ii
  -------------
   {1,2,3,4,5}
--- 1416,1422 ----
      ii integer[]
  );
  
! testdb=&gt; SELECT * FROM t3;
       ii
  -------------
   {1,2,3,4,5}
diff --git a/doc/src/sgml/hstore.sgml b/doc/src/sgml/hstore.sgml
index aa21295..0f1b6b4 100644
*** a/doc/src/sgml/hstore.sgml
--- b/doc/src/sgml/hstore.sgml
*************** b
*** 380,386 ****
        <entry><type>hstore</type></entry>
        <entry>delete pair with matching key</entry>
        <entry><literal>delete('a=&gt;1,b=&gt;2','b')</literal></entry>
!       <entry><literal>"a"=>"1"</literal></entry>
       </row>
  
       <row>
--- 380,386 ----
        <entry><type>hstore</type></entry>
        <entry>delete pair with matching key</entry>
        <entry><literal>delete('a=&gt;1,b=&gt;2','b')</literal></entry>
!       <entry><literal>"a"=&gt;"1"</literal></entry>
       </row>
  
       <row>
*************** b
*** 388,394 ****
        <entry><type>hstore</type></entry>
        <entry>delete pairs with matching keys</entry>
        <entry><literal>delete('a=&gt;1,b=&gt;2,c=&gt;3',ARRAY['a','b'])</literal></entry>
!       <entry><literal>"c"=>"3"</literal></entry>
       </row>
  
       <row>
--- 388,394 ----
        <entry><type>hstore</type></entry>
        <entry>delete pairs with matching keys</entry>
        <entry><literal>delete('a=&gt;1,b=&gt;2,c=&gt;3',ARRAY['a','b'])</literal></entry>
!       <entry><literal>"c"=&gt;"3"</literal></entry>
       </row>
  
       <row>
*************** b
*** 396,402 ****
        <entry><type>hstore</type></entry>
        <entry>delete pairs matching those in the second argument</entry>
        <entry><literal>delete('a=&gt;1,b=&gt;2','a=&gt;4,b=&gt;2'::hstore)</literal></entry>
!       <entry><literal>"a"=>"1"</literal></entry>
       </row>
  
       <row>
--- 396,402 ----
        <entry><type>hstore</type></entry>
        <entry>delete pairs matching those in the second argument</entry>
        <entry><literal>delete('a=&gt;1,b=&gt;2','a=&gt;4,b=&gt;2'::hstore)</literal></entry>
!       <entry><literal>"a"=&gt;"1"</literal></entry>
       </row>
  
       <row>
diff --git a/doc/src/sgml/ltree.sgml b/doc/src/sgml/ltree.sgml
index 0a91cd7..06b262b 100644
*** a/doc/src/sgml/ltree.sgml
--- b/doc/src/sgml/ltree.sgml
*************** a.  b.     c.      d.               e.
*** 108,114 ****
  </programlisting>
       This query will match any label path that:
      </para>
!     <orderedlist numeration='loweralpha'>
       <listitem>
        <para>
         begins with the label <literal>Top</literal>
--- 108,114 ----
  </programlisting>
       This query will match any label path that:
      </para>
!     <orderedlist numeration="loweralpha">
       <listitem>
        <para>
         begins with the label <literal>Top</literal>
diff --git a/doc/src/sgml/pgarchivecleanup.sgml b/doc/src/sgml/pgarchivecleanup.sgml
index ddffa32..4602544 100644
*** a/doc/src/sgml/pgarchivecleanup.sgml
--- b/doc/src/sgml/pgarchivecleanup.sgml
*************** pg_archivecleanup:  removing file "archi
*** 108,114 ****
  
    <para>On Linux or Unix systems, you might use:
  <programlisting>
! archive_cleanup_command = 'pg_archivecleanup -d /mnt/standby/archive %r 2>>cleanup.log'
  </programlisting>
     where the archive directory is physically located on the standby server,
     so that the <varname>archive_command</> is accessing it across NFS,
--- 108,114 ----
  
    <para>On Linux or Unix systems, you might use:
  <programlisting>
! archive_cleanup_command = 'pg_archivecleanup -d /mnt/standby/archive %r 2&gt;&gt;cleanup.log'
  </programlisting>
     where the archive directory is physically located on the standby server,
     so that the <varname>archive_command</> is accessing it across NFS,
diff --git a/doc/src/sgml/pgcrypto.sgml b/doc/src/sgml/pgcrypto.sgml
index 6b78f2c..9abbc34 100644
*** a/doc/src/sgml/pgcrypto.sgml
--- b/doc/src/sgml/pgcrypto.sgml
*************** gpg --list-secret-keys
*** 827,839 ****
    <para>
     To export a public key in ASCII-armor format:
  <programlisting>
! gpg -a --export KEYID > public.key
  </programlisting>
    </para>
    <para>
     To export a secret key in ASCII-armor format:
  <programlisting>
! gpg -a --export-secret-keys KEYID > secret.key
  </programlisting>
    </para>
    <para>
--- 827,839 ----
    <para>
     To export a public key in ASCII-armor format:
  <programlisting>
! gpg -a --export KEYID &gt; public.key
  </programlisting>
    </para>
    <para>
     To export a secret key in ASCII-armor format:
  <programlisting>
! gpg -a --export-secret-keys KEYID &gt; secret.key
  </programlisting>
    </para>
    <para>
diff --git a/doc/src/sgml/pgstandby.sgml b/doc/src/sgml/pgstandby.sgml
index e698cb7..e68bd50 100644
*** a/doc/src/sgml/pgstandby.sgml
--- b/doc/src/sgml/pgstandby.sgml
*************** pg_standby <optional> <replaceable>optio
*** 236,242 ****
  <programlisting>
  archive_command = 'cp %p .../archive/%f'
  
! restore_command = 'pg_standby -d -s 2 -t /tmp/pgsql.trigger.5442 .../archive %f %p %r 2>>standby.log'
  
  recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442'
  </programlisting>
--- 236,242 ----
  <programlisting>
  archive_command = 'cp %p .../archive/%f'
  
! restore_command = 'pg_standby -d -s 2 -t /tmp/pgsql.trigger.5442 .../archive %f %p %r 2&gt;&gt;standby.log'
  
  recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442'
  </programlisting>
*************** recovery_end_command = 'rm -f /tmp/pgsql
*** 280,286 ****
  <programlisting>
  archive_command = 'copy %p ...\\archive\\%f'
  
! restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p %r 2>>standby.log'
  
  recovery_end_command = 'del C:\pgsql.trigger.5442'
  </programlisting>
--- 280,286 ----
  <programlisting>
  archive_command = 'copy %p ...\\archive\\%f'
  
! restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p %r 2&gt;&gt;standby.log'
  
  recovery_end_command = 'del C:\pgsql.trigger.5442'
  </programlisting>
diff --git a/doc/src/sgml/pgstattuple.sgml b/doc/src/sgml/pgstattuple.sgml
index a55b35c..cd1302e 100644
*** a/doc/src/sgml/pgstattuple.sgml
--- b/doc/src/sgml/pgstattuple.sgml
***************
*** 29,35 ****
        target relation's name (optionally schema-qualified).
        For example:
  <programlisting>
! test=> SELECT * FROM pgstattuple('pg_catalog.pg_proc');
  -[ RECORD 1 ]------+-------
  table_len          | 458752
  tuple_count        | 1470
--- 29,35 ----
        target relation's name (optionally schema-qualified).
        For example:
  <programlisting>
! test=&gt; SELECT * FROM pgstattuple('pg_catalog.pg_proc');
  -[ RECORD 1 ]------+-------
  table_len          | 458752
  tuple_count        | 1470
*************** free_percent       | 1.95
*** 142,148 ****
        <function>pgstatindex</function> returns a record showing information
        about a B-tree index.  For example:
  <programlisting>
! test=> SELECT * FROM pgstatindex('pg_cast_oid_index');
  -[ RECORD 1 ]------+------
  version            | 2
  tree_level         | 0
--- 142,148 ----
        <function>pgstatindex</function> returns a record showing information
        about a B-tree index.  For example:
  <programlisting>
! test=&gt; SELECT * FROM pgstatindex('pg_cast_oid_index');
  -[ RECORD 1 ]------+------
  version            | 2
  tree_level         | 0
diff --git a/doc/src/sgml/plhandler.sgml b/doc/src/sgml/plhandler.sgml
index 20021bc..54b88ef 100644
*** a/doc/src/sgml/plhandler.sgml
--- b/doc/src/sgml/plhandler.sgml
*************** CREATE LANGUAGE plsample
*** 166,173 ****
      to allow language-specific checking to be done during
      <xref linkend="sql-createfunction">.
      An inline handler can be provided to allow the language to support
!     anonymous code blocks executed via the <xref linkend="sql-do"
!    > command.
     </para>
  
     <para>
--- 166,172 ----
      to allow language-specific checking to be done during
      <xref linkend="sql-createfunction">.
      An inline handler can be provided to allow the language to support
!     anonymous code blocks executed via the <xref linkend="sql-do"> command.
     </para>
  
     <para>
diff --git a/doc/src/sgml/ref/create_table_as.sgml b/doc/src/sgml/ref/create_table_as.sgml
index e4797b6..3e501a5 100644
*** a/doc/src/sgml/ref/create_table_as.sgml
--- b/doc/src/sgml/ref/create_table_as.sgml
*************** CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY
*** 204,211 ****
      <term><replaceable>query</replaceable></term>
      <listitem>
       <para>
!       A <xref linkend="sql-select"
!      >, <link linkend="sql-table">TABLE</link>,
        or
        <xref linkend="sql-values"> command,
        or an <xref linkend="sql-execute"> command
--- 204,210 ----
      <term><replaceable>query</replaceable></term>
      <listitem>
       <para>
!       A <xref linkend="sql-select">, <link linkend="sql-table">TABLE</link>,
        or
        <xref linkend="sql-values"> command,
        or an <xref linkend="sql-execute"> command
diff --git a/doc/src/sgml/ref/rollback_to.sgml b/doc/src/sgml/ref/rollback_to.sgml
index 1b59af6..97036e4 100644
*** a/doc/src/sgml/ref/rollback_to.sgml
--- b/doc/src/sgml/ref/rollback_to.sgml
*************** ROLLBACK [ WORK | TRANSACTION ] TO [ SAV
*** 64,71 ****
    <title>Notes</title>
  
    <para>
!    Use <xref linkend="SQL-RELEASE-SAVEPOINT"
!   > to destroy a savepoint without
     discarding the effects of commands executed after it was established.
    </para>
  
--- 64,70 ----
    <title>Notes</title>
  
    <para>
!    Use <xref linkend="SQL-RELEASE-SAVEPOINT"> to destroy a savepoint without
     discarding the effects of commands executed after it was established.
    </para>
  
diff --git a/doc/src/sgml/rules.sgml b/doc/src/sgml/rules.sgml
index 1b06519..f54ca91 100644
*** a/doc/src/sgml/rules.sgml
--- b/doc/src/sgml/rules.sgml
*************** CREATE VIEW phone_number AS
*** 1839,1845 ****
  <programlisting>
  CREATE FUNCTION tricky(text, text) RETURNS bool AS $$
  BEGIN
!     RAISE NOTICE '% => %', $1, $2;
      RETURN true;
  END
  $$ LANGUAGE plpgsql COST 0.0000000000000000000001;
--- 1839,1845 ----
  <programlisting>
  CREATE FUNCTION tricky(text, text) RETURNS bool AS $$
  BEGIN
!     RAISE NOTICE '% =&gt; %', $1, $2;
      RETURN true;
  END
  $$ LANGUAGE plpgsql COST 0.0000000000000000000001;
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 8f85df6..31d9347 100644
*** a/doc/src/sgml/runtime.sgml
--- b/doc/src/sgml/runtime.sgml
*************** sysctl -w vm.overcommit_memory=2
*** 1336,1342 ****
      thereby guaranteeing it will not be targeted by the OOM killer.  The
      simplest way to do this is to execute
  <programlisting>
! echo -17 > /proc/self/oom_adj
  </programlisting>
      in the postmaster's startup script just before invoking the postmaster.
      Note that this action must be done as root, or it will have no effect;
--- 1336,1342 ----
      thereby guaranteeing it will not be targeted by the OOM killer.  The
      simplest way to do this is to execute
  <programlisting>
! echo -17 &gt; /proc/self/oom_adj
  </programlisting>
      in the postmaster's startup script just before invoking the postmaster.
      Note that this action must be done as root, or it will have no effect;
diff --git a/doc/src/sgml/seg.sgml b/doc/src/sgml/seg.sgml
index 00bd71d..5d1f546 100644
*** a/doc/src/sgml/seg.sgml
--- b/doc/src/sgml/seg.sgml
***************
*** 40,46 ****
     when you fetch it? Watch:
  
  <screen>
! test=> select 6.50 :: float8 as "pH";
   pH
  ---
  6.5
--- 40,46 ----
     when you fetch it? Watch:
  
  <screen>
! test=&gt; select 6.50 :: float8 as "pH";
   pH
  ---
  6.5
*************** test=> select 6.50 :: float8 as "pH";
*** 66,72 ****
     Check this out:
  
  <screen>
! test=> select '6.25 .. 6.50'::seg as "pH";
            pH
  ------------
  6.25 .. 6.50
--- 66,72 ----
     Check this out:
  
  <screen>
! test=&gt; select '6.25 .. 6.50'::seg as "pH";
            pH
  ------------
  6.25 .. 6.50
*************** test=> select '6.25 .. 6.50'::seg as "pH
*** 359,365 ****
     boundary if the resulting interval includes a power of ten:
  
  <screen>
! postgres=> select '10(+-)1'::seg as seg;
        seg
  ---------
  9.0 .. 11             -- should be: 9 .. 11
--- 359,365 ----
     boundary if the resulting interval includes a power of ten:
  
  <screen>
! postgres=&gt; select '10(+-)1'::seg as seg;
        seg
  ---------
  9.0 .. 11             -- should be: 9 .. 11
diff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgml
index dba5bd6..ef228e3 100644
*** a/doc/src/sgml/textsearch.sgml
--- b/doc/src/sgml/textsearch.sgml
*************** ts_headline(<optional> <replaceable clas
*** 1092,1098 ****
         if they contain spaces or commas.
        </para>
       </listitem>
!      <listitem >
        <para>
         <literal>MaxWords</>, <literal>MinWords</literal>: these numbers
         determine the longest and shortest headlines to output.
--- 1092,1098 ----
         if they contain spaces or commas.
        </para>
       </listitem>
!      <listitem>
        <para>
         <literal>MaxWords</>, <literal>MinWords</literal>: these numbers
         determine the longest and shortest headlines to output.
diff --git a/doc/src/sgml/user-manag.sgml b/doc/src/sgml/user-manag.sgml
index d96ff77..8508dd1 100644
*** a/doc/src/sgml/user-manag.sgml
--- b/doc/src/sgml/user-manag.sgml
*************** CREATE USER <replaceable>name</replaceab
*** 244,252 ****
  
      A role's attributes can be modified after creation with
      <command>ALTER ROLE</command>.<indexterm><primary>ALTER ROLE</></>
!     See the reference pages for the <xref linkend="sql-createrole"
!    > and <xref linkend="sql-alterrole"
!    > commands for details.
     </para>
  
    <tip>
--- 244,251 ----
  
      A role's attributes can be modified after creation with
      <command>ALTER ROLE</command>.<indexterm><primary>ALTER ROLE</></>
!     See the reference pages for the <xref linkend="sql-createrole"> and
!     <xref linkend="sql-alterrole"> commands for details.
     </para>
  
    <tip>
diff --git a/doc/src/sgml/xml2.sgml b/doc/src/sgml/xml2.sgml
index 47bac31..0ec55fc 100644
*** a/doc/src/sgml/xml2.sgml
--- b/doc/src/sgml/xml2.sgml
*************** xpath_table('article_id',
*** 297,303 ****
              'article_xml',
              'articles',
              '/article/author|/article/pages|/article/title',
!             'date_entered > ''2003-01-01'' ')
  AS t(article_id integer, author text, page_count integer, title text);
  </programlisting>
     The <literal>AS</> clause defines the names and types of the columns in the
--- 297,303 ----
              'article_xml',
              'articles',
              '/article/author|/article/pages|/article/title',
!             'date_entered &gt; ''2003-01-01'' ')
  AS t(article_id integer, author text, page_count integer, title text);
  </programlisting>
     The <literal>AS</> clause defines the names and types of the columns in the
*************** AS t(article_id integer, author text, pa
*** 329,335 ****
  SELECT t.title, p.fullname, p.email
  FROM xpath_table('article_id', 'article_xml', 'articles',
                   '/article/title|/article/author/@id',
!                  'xpath_string(article_xml,''/article/@date'') > ''2003-03-20'' ')
         AS t(article_id integer, title text, author_id integer),
       tblPeopleInfo AS p
  WHERE t.author_id = p.person_id;
--- 329,335 ----
  SELECT t.title, p.fullname, p.email
  FROM xpath_table('article_id', 'article_xml', 'articles',
                   '/article/title|/article/author/@id',
!                  'xpath_string(article_xml,''/article/@date'') &gt; ''2003-03-20'' ')
         AS t(article_id integer, title text, author_id integer),
       tblPeopleInfo AS p
  WHERE t.author_id = p.person_id;
-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs

Reply via email to