[systemd-commits] 3 commits - man/custom-html.xsl src/journal src/systemctl

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri May 3 17:32:34 PDT 2013


 man/custom-html.xsl        |   78 +++++++++++++++++++++++++++++++++++++++++++++
 src/journal/journal-file.c |   24 ++++++++-----
 src/systemctl/systemctl.c  |    3 -
 3 files changed, 93 insertions(+), 12 deletions(-)

New commits:
commit 20089f95e83dd6a3e9238b3448ce2e55536184ff
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri May 3 20:25:57 2013 -0400

    man: provide "permalinks" to sections and terms
    
    So no one needs to say "go to fd.o/software/systemd/man, open page X,
    then scroll down to section 3, and look for ..." anymore.

diff --git a/man/custom-html.xsl b/man/custom-html.xsl
index c4099b2..2e40ab1 100644
--- a/man/custom-html.xsl
+++ b/man/custom-html.xsl
@@ -33,8 +33,86 @@
   </a>
 </xsl:template>
 
+<xsl:template match="refsect1/title|refsect1/info/title">
+  <!-- the ID is output in the block.object call for refsect1 -->
+  <h2>
+    <xsl:attribute name="id">
+      <xsl:call-template name="inline.charseq"/>
+    </xsl:attribute>
+    <xsl:apply-templates/>
+    <a>
+      <xsl:attribute name="class">
+        <xsl:text>headerlink</xsl:text>
+      </xsl:attribute>
+      <xsl:attribute name="title">
+        <xsl:text>Permalink to this headline</xsl:text>
+      </xsl:attribute>
+      <xsl:attribute name="href">
+        <!--        <xsl:call-template name="href.target.uri" /> -->
+        <xsl:text>#</xsl:text>
+        <xsl:call-template name="inline.charseq"/>
+      </xsl:attribute>
+      <xsl:text>¶</xsl:text>
+    </a>
+  </h2>
+</xsl:template>
+
+<xsl:template match="varlistentry">
+  <dt>
+    <xsl:attribute name="id">
+      <xsl:call-template name="inline.charseq">
+        <xsl:with-param name="content">
+          <xsl:copy-of select="term[position()=1]" />
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:attribute>
+    <xsl:apply-templates select="term"/>
+    <a>
+      <xsl:attribute name="class">
+        <xsl:text>headerlink</xsl:text>
+      </xsl:attribute>
+      <xsl:attribute name="title">
+        <xsl:text>Permalink to this term</xsl:text>
+      </xsl:attribute>
+      <xsl:attribute name="href">
+        <!--        <xsl:call-template name="href.target.uri" /> -->
+        <xsl:text>#</xsl:text>
+        <xsl:call-template name="inline.charseq">
+          <xsl:with-param name="content">
+            <xsl:copy-of select="term[position()=1]" />
+          </xsl:with-param>
+        </xsl:call-template>
+      </xsl:attribute>
+      <xsl:text>¶</xsl:text>
+    </a>
+  </dt>
+  <dd>
+    <xsl:apply-templates select="listitem"/>
+  </dd>
+</xsl:template>
+
+
 <!-- add Index link at top of page -->
 <xsl:template name="user.header.content">
+  <style>
+    a.headerlink {
+      color: #c60f0f;
+      font-size: 0.8em;
+      padding: 0 4px 0 4px;
+      text-decoration: none;
+      visibility: hidden;
+    }
+
+    a.headerlink:hover {
+      background-color: #c60f0f;
+      color: white;
+    }
+
+    h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
+      visibility: visible;
+    }
+  </style>
+
   <a>
     <xsl:attribute name="href">
       <xsl:text>index.html</xsl:text>

commit e9dd0369e4b3fa05569521eb83ff8142e6dd9a7c
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri May 3 19:56:54 2013 -0400

    systemctl: use GREEDY_REALLOC in one more place

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 1905d0c..3cca861 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1295,8 +1295,7 @@ static int list_jobs(DBusConnection *bus, char **args) {
                         goto finish;
                 }
 
-                if (!greedy_realloc((void**) &jobs, &size,
-                                    sizeof(struct job_info) * (used + 1))) {
+                if (!GREEDY_REALLOC(jobs, size, used + 1)) {
                         r = log_oom();
                         goto finish;
                 }

commit 47838ab3250d975cf4c23819ee695ed0e9861c04
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri May 3 19:56:18 2013 -0400

    journal: as a µ-opt, use sizeof instead of strlen

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index f0be24c..6eb905e 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -1830,6 +1830,17 @@ static int test_object_monotonic(JournalFile *f, uint64_t p, uint64_t needle) {
                 return TEST_RIGHT;
 }
 
+static inline int find_data_object_by_boot_id(
+                JournalFile *f,
+                sd_id128_t boot_id,
+                Object **o,
+                uint64_t *b) {
+        char t[sizeof("_BOOT_ID=")-1 + 32 + 1] = "_BOOT_ID=";
+
+        sd_id128_to_string(boot_id, t + 9);
+        return journal_file_find_data_object(f, t, sizeof(t) - 1, o, b);
+}
+
 int journal_file_move_to_entry_by_monotonic(
                 JournalFile *f,
                 sd_id128_t boot_id,
@@ -1838,14 +1849,12 @@ int journal_file_move_to_entry_by_monotonic(
                 Object **ret,
                 uint64_t *offset) {
 
-        char t[9+32+1] = "_BOOT_ID=";
         Object *o;
         int r;
 
         assert(f);
 
-        sd_id128_to_string(boot_id, t + 9);
-        r = journal_file_find_data_object(f, t, strlen(t), &o, NULL);
+        r = find_data_object_by_boot_id(f, boot_id, &o, NULL);
         if (r < 0)
                 return r;
         if (r == 0)
@@ -2059,7 +2068,6 @@ int journal_file_move_to_entry_by_monotonic_for_data(
                 direction_t direction,
                 Object **ret, uint64_t *offset) {
 
-        char t[9+32+1] = "_BOOT_ID=";
         Object *o, *d;
         int r;
         uint64_t b, z;
@@ -2067,8 +2075,7 @@ int journal_file_move_to_entry_by_monotonic_for_data(
         assert(f);
 
         /* First, seek by time */
-        sd_id128_to_string(boot_id, t + 9);
-        r = journal_file_find_data_object(f, t, strlen(t), &o, &b);
+        r = find_data_object_by_boot_id(f, boot_id, &o, &b);
         if (r < 0)
                 return r;
         if (r == 0)
@@ -2807,7 +2814,6 @@ int journal_file_get_cutoff_realtime_usec(JournalFile *f, usec_t *from, usec_t *
 }
 
 int journal_file_get_cutoff_monotonic_usec(JournalFile *f, sd_id128_t boot_id, usec_t *from, usec_t *to) {
-        char t[9+32+1] = "_BOOT_ID=";
         Object *o;
         uint64_t p;
         int r;
@@ -2815,9 +2821,7 @@ int journal_file_get_cutoff_monotonic_usec(JournalFile *f, sd_id128_t boot_id, u
         assert(f);
         assert(from || to);
 
-        sd_id128_to_string(boot_id, t + 9);
-
-        r = journal_file_find_data_object(f, t, strlen(t), &o, &p);
+        r = find_data_object_by_boot_id(f, boot_id, &o, &p);
         if (r <= 0)
                 return r;
 



More information about the systemd-commits mailing list