diff lib-src/make-docfile.c @ 102:a145efe76779 r20-1b3

Import from CVS: tag r20-1b3
author cvs
date Mon, 13 Aug 2007 09:15:49 +0200
parents 6a378aca36af
children 8eaf7971accc
line wrap: on
line diff
--- a/lib-src/make-docfile.c	Mon Aug 13 09:15:13 2007 +0200
+++ b/lib-src/make-docfile.c	Mon Aug 13 09:15:49 2007 +0200
@@ -33,6 +33,9 @@
  Then comes F for a function or V for a variable.
  Then comes the function or variable name, terminated with a newline.
  Then comes the documentation for that function or variable.
+
+ Added 19.15/20.1:  `-i site-packages' allow installer to dump extra packages
+ without modifying Makefiles, etc.
  */
 
 #define NO_SHORTNAMES   /* Tell config not to load remap.h */
@@ -74,6 +77,7 @@
 
 /* Stdio stream for output to the DOC file.  */
 static FILE *outfile;
+static char *extra_elcs = NULL;
 
 enum
 {
@@ -130,6 +134,41 @@
   return result;
 }
 
+static char *
+next_extra_elc(char *extra_elcs)
+{
+  static FILE *fp = NULL;
+  static char line_buf[BUFSIZ];
+  char *p = line_buf+1;
+
+  if (!fp) {
+    if (!extra_elcs) {
+      return NULL;
+    } else if (!(fp = fopen(extra_elcs, "r"))) {
+      /* It is not an error if this file doesn't exist. */
+      /*fatal("error opening site package file list", 0);*/
+      return NULL;
+    }
+    fgets(line_buf, BUFSIZ, fp);
+  }
+
+again:
+  if (!fgets(line_buf, BUFSIZ, fp)) {
+    fclose(fp);
+    fp = NULL;
+    return NULL;
+  }
+  line_buf[0] = '\0';
+  if (strlen(p) <= 2 || strlen(p) >= (BUFSIZ - 5)) {
+    /* reject too short or too long lines */
+    goto again;
+  }
+  p[strlen(p) - 2] = '\0';
+  strcat(p, ".elc");
+
+  return p;
+}
+
 
 int
 main (int argc, char **argv)
@@ -175,6 +214,11 @@
       i += 2;
     }
 
+  if (argc > (i + 1) && !strcmp(argv[i], "-i")) {
+    extra_elcs = argv[i + 1];
+    i += 2;
+  }
+
   if (outfile == 0)
     fatal ("No output file specified", "");
 
@@ -190,6 +234,15 @@
 	/* err_count seems to be {mis,un}used */
 	err_count += scan_file (argv[i]);
     }
+
+  if (extra_elcs) {
+    char *p;
+
+    while ((p = next_extra_elc(extra_elcs)) != NULL) {
+      err_count += scan_file(p);
+    }
+  }
+
   putc ('\n', outfile);
 #ifndef VMS
   exit (err_count > 0);