home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / admin / m2errlst.mod < prev    next >
Text File  |  1995-05-03  |  5KB  |  155 lines

  1. (*
  2.  * =========== macro processed output from MPP  ==========
  3.  *
  4.  * input file  : m2errlst.mpp
  5.  * time stamp  : 1995 Apr 26 16:09:00
  6.  *
  7.  * output file : m2errlst.mod
  8.  * created at  : 1995 May 03 16:13:56
  9.  *
  10.  * options ... :  -Dalpha
  11.  *
  12.  * =======================================================
  13.  *)
  14.  
  15. (* -- RCS Header --
  16.         $Log:    m2errlst.mpp,v $
  17. Revision 1.3  94/03/02  15:01:12  mboss
  18. Changed error list file to m2errlst.dat, same as pc and native code.:wq
  19.  
  20. Revision 1.2  94/02/28  14:10:05  mboss
  21. Increased file size and index size
  22.  
  23. Revision 1.1  94/01/12  15:37:13  mboss
  24. Initial revision
  25.  
  26. *)
  27.  
  28. (* 
  29.  *  extracted with 
  30.  *         "opsys" == "sysV           # actually OSF/1"
  31.  *        "endian" == "little"
  32.  *    "processor" == "alpha_risc"
  33.  *)
  34.  
  35. (*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*)
  36. (* This is the utility program which takes the error    *)
  37. (* message file for Gardens Point Modula and processes  *)
  38. (* it into the form necessary for use by M2InOut        *)
  39.  
  40. (* Format of the text file is:                          *)
  41. (*      textFile = {comment | message} nul.             *)
  42. (*      comment  = 'line not starting with number'.     *)
  43. (*      message  = number errMess.                      *)
  44. (*      number   = 'an ascii decimal number'.           *)
  45.  
  46. (* Format of the output table is:                       *)
  47. (*      outTable = index textFile.                      *)
  48. (*      index    = ARRAY[0 .. 512] OF CARDINAL;         *)
  49. (* each index entry is an index into the output table   *)
  50. (* and indexes the corresponding number.errMess string  *)
  51. (*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*)
  52.  
  53. MODULE M2ErrLst;
  54.  
  55. (*
  56.   Revisions:
  57.  
  58.   24-Mar-92  jrh  Remove 'old' format
  59.           (input m2errs.txt -> output m2errlst.dat);
  60.           'new' format with verbose error message text is
  61.           input errmess.txt -> output m2errlst.dat2.
  62.   12-Nov-92  jrh  Further size increase.
  63.   28-Feb-94  pms  Further size and index increase 5300 & 600
  64.   02-Mar-94  pms  Error list file now m2errlst.dat same as pc and native code.
  65. *)
  66.  
  67.   IMPORT SYSTEM, Types;
  68.   FROM Terminal IMPORT WriteString, WriteLn, Write, WriteCard;
  69.   FROM ProgArgs IMPORT UNIXexit, EnvironString;
  70.   FROM PathLookup IMPORT FindAndOpen;
  71.   FROM UxFiles IMPORT Open, OpenMode, Create, Close,
  72.              ReadNBytes, WriteByte, File;
  73.  
  74.   CONST bytesInWord = 4;
  75.   CONST eol      = 12C;
  76.         fileSize = 53000; (* >= bytes in m2errs.txt *)
  77.         indexSiz = 600;
  78.         chrStart = indexSiz * bytesInWord;
  79.         totalSiz = chrStart + fileSize; (*  9000 @ 10-Apr-89 *)
  80.                     (* 10000 @ 16-Aug-89 *)
  81.                     (* 50000      Mar-92 *)
  82.                     (* 52048      Nov-92 *)
  83.                                         (* 55400      Mar-94 *)
  84.  
  85.   VAR   ch    : CHAR;
  86.         ok    : BOOLEAN;
  87.         read  : CARDINAL;
  88.         ix,lx : CARDINAL;
  89.         total : CARDINAL;
  90.         table : RECORD
  91.                   CASE (* no tag *) : BOOLEAN OF
  92.                   | TRUE  : index : ARRAY [1 .. indexSiz] OF Types.Card32;
  93.                   | FALSE : chars : ARRAY [0 .. totalSiz] OF CHAR;
  94.                   END;
  95.                 END;
  96.         pathStr, absName : ARRAY [0 .. 131] OF CHAR;
  97.         errFile, outFile : File;
  98.  
  99. BEGIN
  100.   FindAndOpen(".","m2errs.txt",absName,errFile);
  101.   IF errFile = NIL THEN
  102.     EnvironString("PATH",pathStr);
  103.     FindAndOpen(pathStr,"m2errs.txt",absName,errFile);
  104.   END;
  105.   IF errFile <> NIL THEN
  106.     WriteString("Reading ");
  107.     WriteString(absName); WriteLn;
  108.   ELSE
  109.     WriteString("**** m2errs.txt not found ****");
  110.     WriteLn; UNIXexit(1);
  111.   END;
  112.   FOR ix := 1 TO indexSiz DO table.index[ix] := 0 END;
  113.   Create(outFile,"m2errlst.dat",ok);
  114.   IF NOT ok THEN
  115.     WriteString("**** Can't create m2errlst.dat ****");
  116.     WriteLn; UNIXexit(1);
  117.   END;
  118.   ReadNBytes(errFile,
  119.              SYSTEM.ADR(table.chars[chrStart]),
  120.              fileSize,
  121.              read);
  122.   Close(errFile,ok);
  123.   ix := chrStart;
  124.   ch := table.chars[ix];
  125.   WHILE ch <> 0C DO (* another line *)
  126.     lx := ix;
  127.     WHILE ch = " " DO (* skip leading blanks *)
  128.       INC(ix); ch := table.chars[ix];
  129.     END;
  130.     (*
  131.        now, is there a number starting the line?
  132.     *)
  133.     IF ("0" <= ch) AND (ch <= "9") THEN
  134.       total := 0;
  135.       WHILE ("0" <= ch) AND (ch <= "9") DO
  136.         total := total * 10 + ORD(ch) - ORD("0");
  137.         INC(ix); ch := table.chars[ix];
  138.       END;
  139.       table.index[total] := lx;        
  140.     END;
  141.     (*
  142.        now find end of line
  143.     *)
  144.     WHILE (ch <> eol) AND (ch <> 0C) DO
  145.       INC(ix); ch := table.chars[ix];
  146.     END;
  147.     IF ch = eol THEN INC(ix); ch := table.chars[ix] END;
  148.   END; (* while *)  
  149.   FOR ix := 0 TO chrStart + read DO 
  150.     WriteByte(outFile,table.chars[ix]);
  151.   END;
  152.   Close(outFile,ok);
  153. END M2ErrLst.
  154.  
  155.