home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / docs / src / contents2html.gawk < prev    next >
Encoding:
Text File  |  1997-01-24  |  1.0 KB  |  65 lines

  1. BEGIN {
  2.     indent="";
  3.  
  4. #    for (t=0; t<ARGC; t++)
  5. #     print t":"ARGV[t];
  6.  
  7.     if (ARGC > 1)
  8.     proccontents(ARGV[1],TOP);
  9. }
  10.  
  11. function proccontents(file,top  ,t,dir,tmp_dir,text,desc) {
  12.     desc=0;
  13. #   print "Working on " top
  14.     while ((getline < file) > 0)
  15.     {
  16.     if (match ($0,/^[-a-zA-Z0-9_./]+[ \t]+-[ \t]*/))
  17.     {
  18.         if (!desc)
  19.         {
  20.         print indent"\\begin{description}"
  21.         desc=1;
  22.         }
  23.  
  24.         text=substr($0,RSTART+RLENGTH);
  25.         tmp_dir=$1;
  26.         if (dir != "")
  27.         {
  28.         gsub("/$","",dir);
  29.         #print "Looking for "top"/"dir"/contents"
  30.         for (t=1; t<ARGC; t++)
  31.         {
  32.             if (ARGV[t] == top"/"dir"/contents")
  33.             {
  34.             indent=indent"    "
  35.             proccontents(ARGV[t],top"/"dir);
  36.             indent=substr(indent,5);
  37.             }
  38.         }
  39.         }
  40.  
  41.         dir=tmp_dir;
  42.  
  43.         print indent"\\item{"dir"} "text
  44.     }
  45.     else
  46.         print
  47.     }
  48.  
  49.     if (dir!="")
  50.     {
  51.     gsub("/$","",dir);
  52.     for (t=1; t<ARGC; t++)
  53.     {
  54.         if (ARGV[t] == top"/"dir"/contents")
  55.         {
  56.         indent=indent"    "
  57.         proccontents(ARGV[t],top"/"dir);
  58.         indent=substr(indent,5);
  59.         }
  60.     }
  61.     }
  62.  
  63.     print indent"\\end{description}\n"
  64. }
  65.