[svn] dirmngr - r262 - in trunk: . doc src

svn author wk cvs at cvs.gnupg.org
Tue Aug 14 19:40:57 CEST 2007


Author: wk
Date: 2007-08-14 19:40:27 +0200 (Tue, 14 Aug 2007)
New Revision: 262

Modified:
   trunk/ChangeLog
   trunk/doc/yat2m.c
   trunk/src/ChangeLog
   trunk/src/get-path.c
Log:
Changed the default path for the socket.
Updated yat2m.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-08-13 13:32:46 UTC (rev 261)
+++ trunk/ChangeLog	2007-08-14 17:40:27 UTC (rev 262)
@@ -1,3 +1,7 @@
+2007-08-14  Werner Koch  <wk at g10code.com>
+
+	* doc/yat2m.c: Updated from current GnuPG SVN.
+
 2007-08-12  Werner Koch  <wk at g10code.com>
 
 	* doc/Makefile.am (yat2m): Change the way this helper is build.

Modified: trunk/doc/yat2m.c
===================================================================
--- trunk/doc/yat2m.c	2007-08-13 13:32:46 UTC (rev 261)
+++ trunk/doc/yat2m.c	2007-08-14 17:40:27 UTC (rev 262)
@@ -4,7 +4,7 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,9 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -105,11 +103,27 @@
 static const char *opt_include;
 static int opt_store;
 
+/* The only define we understand is -D gpgone.  Thus we need a simple
+   boolean tro track it. */
+static int gpgone_defined;
 
 /* Flag to keep track whether any error occurred.  */
 static int any_error;
 
 
+/* Object to keep macro definitions.  */
+struct macro_s
+{
+  struct macro_s *next;
+  char *value;  /* Malloced value. */
+  char name[1];
+};
+typedef struct macro_s *macro_t;
+
+/* List of all defined macros. */
+static macro_t macrolist;
+
+
 /* Object to store one line of content.  */
 struct line_buffer_s
 {
@@ -435,7 +449,7 @@
     { "code",    0, "\\fB", "\\fR" },
     { "sc",      0, "\\fB", "\\fR" },
     { "var",     0, "\\fI", "\\fR" },
-    { "samp",    0, "\n'",  "'\n"  },
+    { "samp",    0, "'",  "'"  },
     { "file",    0, "`\\fI","\\fR'" }, 
     { "env",     0, "`\\fI","\\fR'" }, 
     { "acronym", 0 },
@@ -456,7 +470,6 @@
     { "opindex", 1 },
     { "cpindex", 1 },
     { "cindex",  1 },
-    { "node",    1 },
     { "noindent", 0 },
     { "section", 1 },
     { "chapter", 1 },
@@ -465,10 +478,10 @@
     { "item",    2, ".TP\n.B " },
     { "itemx",   2, ".TP\n.B " },
     { "table",   3 }, 
+    { "itemize",   3 }, 
+    { "bullet",  0, "* " },
     { "end",     4 },
     { "quotation",1, ".RS\n\\fB" },
-    { "ifset",   1 },
-    { "ifclear",   1 },
     { NULL }
   };
   size_t n;
@@ -523,11 +536,6 @@
             {
               fputs ("\\fR\n.RE\n", fp);
             }
-          else if (n >= 5 && !memcmp (s, "ifset", 5)
-              && (!n || s[5] == ' ' || s[5] == '\t' || s[5] == '\n'))
-            {
-              fputs ("\\fR\n.RE\n", fp);
-            }
           /* Now throw away the entire line. */
           s = memchr (rest, '\n', len);
           return s? (s-rest)+1 : len;  
@@ -555,8 +563,20 @@
     }
   else
     {
-      inf ("texinfo command `%s' not supported (%.*s)", command,
-           ((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest);
+      macro_t m;
+
+      for (m = macrolist; m ; m = m->next)
+        if (!strcmp (m->name, command))
+            break;
+      if (m)
+        {
+          proc_texi_buffer (fp, m->value, strlen (m->value),
+                            table_level, eol_action);
+          ignore_args = 1; /* Parameterized macros are not yet supported. */
+        }
+      else
+        inf ("texinfo command `%s' not supported (%.*s)", command,
+             ((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest);
     }
 
   if (*rest == '{')
@@ -658,6 +678,16 @@
       else
         putc (*s, fp);
     }
+
+  if (in_cmd > 1)
+    {
+      cmdbuf[cmdidx] = 0;
+      n = proc_texi_cmd (fp, cmdbuf, s, len, table_level, eol_action);
+      assert (n <= len);
+      s += n; len -= n;
+      s--; len++;
+      in_cmd = 0;
+    }
 }
 
 
@@ -723,7 +753,7 @@
 finish_page (void)
 {
   FILE *fp;
-  section_buffer_t sect;
+  section_buffer_t sect = NULL;
   int idx;
   const char *s;
   int i;
@@ -812,10 +842,23 @@
 {
   char *line;
   int lnr = 0;
+  /* Fixme: The follwing state variables don't carry over to include
+     files. */
   int in_verbatim = 0;
   int skip_to_end = 0;        /* Used to skip over menu entries. */
   int skip_sect_line = 0;     /* Skip after @mansect.  */
+  int ifset_nesting = 0;      /* How often a ifset has been seen. */
+  int ifclear_nesting = 0;    /* How often a ifclear has been seen. */
+  int in_gpgone = 0;          /* Keep track of "@ifset gpgone" parts.  */
+  int not_in_gpgone = 0;      /* Keep track of "@ifclear gpgone" parts.  */
+  int not_in_man = 0;         /* Keep track of "@ifclear isman" parts.  */
 
+  /* Helper to define a macro. */
+  char *macroname = NULL;     
+  char *macrovalue = NULL; 
+  size_t macrovaluesize = 0;
+  size_t macrovalueused = 0;
+
   line = xmalloc (LINESIZE);
   while (fgets (line, LINESIZE, fp))
     {
@@ -826,12 +869,77 @@
       lnr++;
       if (!n || line[n-1] != '\n')
         {
-          err ("%s:$d: trailing linefeed missing, line too long or "
+          err ("%s:%d: trailing linefeed missing, line too long or "
                "embedded Nul character", fname, lnr);
           break;
         }
       line[--n] = 0;
 
+      if (*line == '@')
+        {
+          for (p=line+1, n=1; *p && *p != ' ' && *p != '\t'; p++)
+            n++;
+          while (*p == ' ' || *p == '\t')
+            p++;
+        }
+      else
+        p = line;
+
+      /* Take action on macro.  */
+      if (macroname)
+        {
+          if (n == 4 && !memcmp (line, "@end", 4)
+              && (line[4]==' '||line[4]=='\t'||!line[4])
+              && !strncmp (p, "macro", 5)
+              && (p[5]==' '||p[5]=='\t'||!p[5]))
+            {
+              macro_t m;
+
+              if (macrovalueused)
+                macrovalue[--macrovalueused] = 0; /* Kill the last LF. */
+              macrovalue[macrovalueused] = 0;     /* Terminate macro. */
+              macrovalue = xrealloc (macrovalue, macrovalueused+1);
+              
+              for (m= macrolist; m; m = m->next)
+                if (!strcmp (m->name, macroname))
+                  break;
+              if (m)
+                free (m->value);
+              else
+                {
+                  m = xcalloc (1, sizeof *m + strlen (macroname));
+                  strcpy (m->name, macroname);
+                  m->next = macrolist;
+                  macrolist = m;
+                }
+              m->value = macrovalue;
+              macrovalue = NULL;
+              free (macroname);
+              macroname = NULL;
+            }
+          else
+            {
+              if (macrovalueused + strlen (line) + 2 >= macrovaluesize)
+                {
+                  macrovaluesize += strlen (line) + 256;
+                  macrovalue = xrealloc (macrovalue,  macrovaluesize);
+                }
+              strcpy (macrovalue+macrovalueused, line);
+              macrovalueused += strlen (line);
+              macrovalue[macrovalueused++] = '\n';
+            }
+          continue;
+        }
+
+
+      if (n >= 5 && !memcmp (line, "@node", 5)
+          && (line[5]==' '||line[5]=='\t'||!line[5]))
+        {
+          /* Completey ignore @node lines.  */
+          continue;
+        }
+
+
       if (skip_sect_line)
         {
           skip_sect_line = 0;
@@ -845,37 +953,116 @@
          few macros used to control this as well as one @ifset
          command.  Parts we know about are saved away into containers
          separate for each section. */
+
+      /* First process ifset/ifclear commands. */
       if (*line == '@')
         {
-          for (p=line+1, n=1; *p && *p != ' ' && *p != '\t'; p++)
-            n++;
-          while (*p == ' ' || *p == '\t')
-            p++;
+          if (n == 6 && !memcmp (line, "@ifset", 6)
+                   && (line[6]==' '||line[6]=='\t'))
+            {
+              ifset_nesting++;
 
+              if (!strncmp (p, "manverb", 7) && (p[7]==' '||p[7]=='\t'||!p[7]))
+                {
+                  if (in_verbatim)
+                    err ("%s:%d: nested \"@ifset manverb\"", fname, lnr);
+                  else
+                    in_verbatim = ifset_nesting;
+                }
+              else if (!strncmp (p, "gpgone", 6)
+                       && (p[6]==' '||p[6]=='\t'||!p[6]))
+                {
+                  if (in_gpgone)
+                    err ("%s:%d: nested \"@ifset gpgone\"", fname, lnr);
+                  else
+                    in_gpgone = ifset_nesting;
+                }
+              continue;
+            }
+          else if (n == 4 && !memcmp (line, "@end", 4)
+                   && (line[4]==' '||line[4]=='\t')
+                   && !strncmp (p, "ifset", 5)
+                   && (p[5]==' '||p[5]=='\t'||!p[5]))
+            {
+              if (in_verbatim && ifset_nesting == in_verbatim)
+                in_verbatim = 0;
+              if (in_gpgone && ifset_nesting == in_gpgone)
+                in_gpgone = 0;
+
+              if (ifset_nesting)
+                ifset_nesting--;
+              else
+                err ("%s:%d: unbalanced \"@end ifset\"", fname, lnr);
+              continue;
+            }
+          else if (n == 8 && !memcmp (line, "@ifclear", 8)
+                   && (line[8]==' '||line[8]=='\t'))
+            {
+              ifclear_nesting++;
+
+              if (!strncmp (p, "gpgone", 6)
+                  && (p[6]==' '||p[6]=='\t'||!p[6]))
+                {
+                  if (not_in_gpgone)
+                    err ("%s:%d: nested \"@ifclear gpgone\"", fname, lnr);
+                  else
+                    not_in_gpgone = ifclear_nesting;
+                }
+
+              else if (!strncmp (p, "isman", 5)
+                       && (p[5]==' '||p[5]=='\t'||!p[5]))
+                {
+                  if (not_in_man)
+                    err ("%s:%d: nested \"@ifclear isman\"", fname, lnr);
+                  else
+                    not_in_man = ifclear_nesting;
+                }
+
+              continue;
+            }
+          else if (n == 4 && !memcmp (line, "@end", 4)
+                   && (line[4]==' '||line[4]=='\t')
+                   && !strncmp (p, "ifclear", 7)
+                   && (p[7]==' '||p[7]=='\t'||!p[7]))
+            {
+              if (not_in_gpgone && ifclear_nesting == not_in_gpgone)
+                not_in_gpgone = 0;
+              if (not_in_man && ifclear_nesting == not_in_man)
+                not_in_man = 0;
+
+              if (ifclear_nesting)
+                ifclear_nesting--;
+              else
+                err ("%s:%d: unbalanced \"@end ifclear\"", fname, lnr);
+              continue;
+            }
+        }
+
+      /* Take action on ifset/ifclear.  */
+      if ( (in_gpgone && !gpgone_defined)
+           || (not_in_gpgone && gpgone_defined)
+           || not_in_man)
+        continue;
+
+      /* Process commands. */
+      if (*line == '@')
+        {
           if (skip_to_end
               && n == 4 && !memcmp (line, "@end", 4)
               && (line[4]==' '||line[4]=='\t'||!line[4]))
             {
               skip_to_end = 0;
             }
-          else if (n == 6 && !memcmp (line, "@ifset", 6)
-              && !strncmp (p, "manverb", 7) && (p[7]==' '||p[7]=='\t'||!p[7]))
+          else if (in_verbatim)
             {
-              if (in_verbatim)
-                err ("%s:%d: nested \"@ifset manverb\"", fname, lnr);
-              else
-                in_verbatim = 1;
+                got_line = 1;
             }
-          else if (in_verbatim && n == 4 && !memcmp (line, "@end", 4)
-                   && !strncmp (p, "ifset", 5)
-                   && (p[5]==' '||p[5]=='\t'||!p[5]))
+          else if (n == 6 && !memcmp (line, "@macro", 6))
             {
-              in_verbatim = 0;
+              macroname = xstrdup (p);
+              macrovalue = xmalloc ((macrovaluesize = 1024));
+              macrovalueused = 0;
             }
-          else if (in_verbatim)
-            {
-              got_line = 1;
-            }
           else if (n == 8 && !memcmp (line, "@manpage", 8))
             {
               free (*section_name);
@@ -919,11 +1106,6 @@
             {
               skip_to_end = 1;
             }
-          else if (n == 8 && !memcmp (line, "@ifclear", 8)
-              && !strncmp (p, "isman", 5) && (p[5]==' '||p[5]=='\t'||!p[5]))
-            {
-              skip_to_end = 1;
-            }
           else if (n == 8 && !memcmp (line, "@include", 8)
                    && (line[8]==' '||line[8]=='\t'||!line[8]))
             {
@@ -952,6 +1134,11 @@
                 }
               free (incname);
             }
+          else if (n == 4 && !memcmp (line, "@bye", 4)
+                   && (line[4]==' '||line[4]=='\t'||!line[4]))
+            {
+              break;
+            }
           else if (!skip_to_end)
             got_line = 1;
         }
@@ -966,6 +1153,8 @@
     }
   if (ferror (fp))
     err ("%s:%d: read error: %s", fname, lnr, strerror (errno));
+  free (macroname);
+  free (macrovalue);
   free (line);
 }
 
@@ -975,6 +1164,14 @@
 {
   char *section_name = NULL;  /* Name of the current section or NULL
                                  if not in a section.  */
+  while (macrolist)
+    {
+      macro_t m = macrolist->next;
+      free (m->value);
+      free (m);
+      macrolist = m;
+    }
+
   parse_file (fname, fp, &section_name, 0);
   free (section_name);
   finish_page ();
@@ -1013,7 +1210,8 @@
                 "  --verbose        enable extra informational output\n"
                 "  --debug          enable additional debug output\n"
                 "  --help           display this help and exit\n"
-                "  -I DIR           also search in include DIR\n\n"
+                "  -I DIR           also search in include DIR\n"
+                "  -D gpgone        the only useable define\n\n"
                 "With no FILE, or when FILE is -, read standard input.\n\n"
                 "Report bugs to <bugs at g10code.com>.");
           exit (0);
@@ -1087,6 +1285,16 @@
               argc--; argv++;
             }
         }
+      else if (!strcmp (*argv, "-D"))
+        {
+          argc--; argv++;
+          if (argc)
+            {
+              if (!strcmp (*argv, "gpgone"))
+                gpgone_defined = 1;
+              argc--; argv++;
+            }
+        }
     }          
  
   if (argc > 1)

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2007-08-13 13:32:46 UTC (rev 261)
+++ trunk/src/ChangeLog	2007-08-14 17:40:27 UTC (rev 262)
@@ -1,3 +1,7 @@
+2007-08-14  Werner Koch  <wk at g10code.com>
+
+	* get-path.c (dirmngr_cachedir) [W32]: Use CSIDL_LOCAL_APPDATA.
+
 2007-08-13  Werner Koch  <wk at g10code.com>
 
 	* dirmngr.c (handle_connections): Use a timeout in the accept

Modified: trunk/src/get-path.c
===================================================================
--- trunk/src/get-path.c	2007-08-13 13:32:46 UTC (rev 261)
+++ trunk/src/get-path.c	2007-08-14 17:40:27 UTC (rev 262)
@@ -473,17 +473,28 @@
 dirmngr_cachedir (void)
 {
 #ifdef HAVE_W32_SYSTEM
-  static char *name;
+  static const char *dir;
 
-  if (!name)
+  if (!dir)
     {
-      const char *s1, *s2;
-      s1 = w32_rootdir (); /* FIXME: /var in windows? */
-      s2 = DIRSEP_S "cache" DIRSEP_S "dirmngr";
-      name = xmalloc (strlen (s1) + strlen (s2) + 1);
-      strcpy (stpcpy (name, s1), s2);
+      char path[MAX_PATH];
+      const char *s1;
+      
+      s1 = "\\GNU\\cache\\dirmngr";
+      if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, 
+                               NULL, 0, path) >= 0) 
+        {
+          char *tmp = xmalloc (strlen (path) + strlen (s1) +1);
+          strcpy (stpcpy (tmp, path), s1);
+          dir = tmp;
+
+          if (access (dir, F_OK))
+            CreateDirectory (dir, NULL);
+        }
+      else
+        dir = "c:\\temp\\cache\\dirmngr";
     }
-  return name;
+  return dir;
 #else /*!HAVE_W32_SYSTEM*/
   return DIRMNGR_CACHEDIR;
 #endif /*!HAVE_W32_SYSTEM*/




More information about the Gnupg-commits mailing list