home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / archival / genindex / index-mon2num < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.5 KB  |  62 lines

  1. #!/bin/sh
  2. # $Id: index-mon2num,v 1.1 1992/08/09 16:36:25 cross Exp cross $
  3.  
  4. awk '
  5. BEGIN {
  6.     months[1]  = "Jan"; months[2]  = "Feb"; months[3]  = "Mar";
  7.     months[4]  = "Apr"; months[5]  = "May"; months[6]  = "Jun";
  8.     months[7]  = "Jul"; months[8]  = "Aug"; months[9]  = "Sep";
  9.     months[10] = "Oct"; months[11] = "Nov"; months[12] = "Dec";
  10. }
  11. /^#VERSION/ {
  12.     if ($2 != "1.0") {
  13.     print "wrong version header \"" $2 "\". cannot decode format.";
  14.     exit;
  15.     }
  16.     off=3;
  17.     while(substr($0,off,1) == " " || substr($0,off,1) == "    ")
  18.     off++;
  19.     while(substr($0,off,1) != " " && substr($0,off,1) != "    ")
  20.     off++;
  21.  
  22.     printf("#VERSION (num-month)1.0%s\n", substr($0,off,2048));
  23.     version=1;
  24.     next;
  25. }
  26. /^F/ || /^D/ || /^L/ { 
  27.     if (!version) {
  28.     print "no version (#VERSION) header provided. cannot decode format.";
  29.     exit;
  30.     }
  31.     if (NF < 5) {
  32.     print "illegal format in line " NR;
  33.     exit;
  34.     }
  35.     # must be seeked from left because of embedded spaces in filenames!
  36.     off=0;
  37.     for(i = 0; i < 2; i++) {
  38.     while(substr($0,off,1) != " " && substr($0,off,1) != "    ")
  39.         off++;
  40.     while(substr($0,off,1) == " " || substr($0,off,1) == "    ")
  41.         off++;
  42.     }
  43.     off += 3;
  44.     monthstr=substr($0,off,3);
  45.  
  46.     for(month = 12; month > 0; month--)
  47.     if ( months[month] == monthstr) break;
  48.  
  49.     if (month <= 0) {
  50.     print "illegal month name " monthstr " in line " NR;
  51.     exit;
  52.     }
  53.  
  54.     printf("%s%02d%s\n", substr($0,1,off-1), month, substr($0,off+3,4096));
  55.     next;
  56. }
  57. {
  58.     # comment lines
  59.     print $0;
  60. }
  61. '
  62.