home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 2.ddi / PCLINT.ZIP / IDE-LINT.C
Encoding:
C/C++ Source or Header  |  1990-08-26  |  3.4 KB  |  109 lines

  1. /**************************************************************************
  2. Version   : 1.0
  3. Function  : ProcessLine
  4. Parameters: Line - a pointer to the character line to be analyzed
  5. Returns   : Nothing
  6.  
  7. This function filters lines output from Gimpel's PC-Lint 4.0 into a format
  8. usable in the Turbo C++ environment message window.  Most of the work is
  9. done by correct parameters to LINT so that the lines require very little
  10. processing by this function.
  11.  
  12.  
  13. Substitute this function for the one in GREP2MSG found in the TC++ package.
  14. Then rename the file to LINT2MSG and at the top of the file add:
  15. #include <stdio.h>
  16.  
  17.  
  18. The Options-Transfer-Edit-program Title should be:
  19. ~Lint
  20.  
  21. The Options-Transfer-Edit-program Path should be:
  22. pathspec\LINT
  23.  
  24. The Options-Transfer-Edit-program Command line should be:
  25. pathspec\CO-TC -h1 -w(0,0) "-format=@%f %l %c %t %n: %m" $MEM(256) $NOSWAP
  26.   $CAP MSG(LINT2MSG) $NAME($EXENAME) $SAVE PROMPT
  27.  
  28. The command line above should be on one continious line the the transfer
  29. editor window.  Substitute the correct path to your LINT directory for
  30. pathspec above.
  31.  
  32.  
  33. written by Edward Rayl
  34.  
  35. If you have any comments for improvements please leave a CIS message to:
  36. 73210,3446
  37.  
  38. **************************************************************************/
  39. void ProcessLine(char *Line)
  40. {
  41.   MsgType      Type;
  42.   unsigned     i;
  43.   unsigned     LineNum;
  44.   unsigned     ColNum;
  45.   char         Message[133];
  46.   static char  LastFile[65] = "";
  47.   char         NewFile[65];
  48.   int          NumRead;
  49.  
  50.   if ((Line[0] == 0) ||                /* ignore blank line */
  51.       (Line[0] != '@'))                /* all legal lines start with * */
  52.     return;
  53.  
  54.   memmove(Line,&Line[1],strlen(Line)); /* kill the @ */
  55.  
  56.  
  57.   /* check for new file name */
  58.   if (sscanf(Line, "%64s", NewFile) !=1)
  59.     return;
  60.  
  61.   if (strcmp(NewFile, "0") == 0)       /* handle lines with no file name */
  62.   {
  63.     if (sscanf(Line, "  0 %132[^@]", Message) != 1)
  64.       strcpy(Message, "Error in PC-Lint output stream\n");
  65.     NewFile[0] = '\0';
  66.     if (LastFile[0] != '\0')
  67.     {
  68.       Type = MsgNewFile;               /* indicate new file */
  69.       Put((char *)&Type,1);
  70.       Put(NewFile,(int) strlen(NewFile) + 1);   /* write filename */
  71.       Type = MsgNewLine;               /* put some space in window */
  72.       i = 0;
  73.       Put((char *)&Type,1);
  74.       Put((char *)&i,2);
  75.       Put((char *)&i,2);
  76.       Put(" ",2);
  77.     }
  78.     LastFile[0] = '\0';
  79.     LineNum  = 0;
  80.     ColNum   = 0;
  81.   }
  82.   else
  83.   {
  84.     if (strcmp(LastFile,NewFile) != 0)
  85.     {
  86.       strcpy(LastFile,NewFile);
  87.       Type = MsgNewFile;               /* indicate new file */
  88.       Put((char *)&Type,1);
  89.       Put(NewFile,(int) strlen(NewFile) + 1);   /* write filename */
  90.     }
  91.     memmove(Line,&Line[strlen(NewFile)] + 1,strlen(Line));
  92.     NoLines = FALSE;                   /* message lines output */
  93.     Type = MsgNewLine;                 /* new line in message window */
  94.  
  95.     if (sscanf(Line, "%u %u %132[^@]", &LineNum, &ColNum, Message) != 3)
  96.     {
  97.       strcpy(Message, "Error in PC-Lint output stream\n");
  98.       LastFile[0] = '\0';
  99.       LineNum  = 0;
  100.       ColNum   = 0;
  101.     }
  102.   }
  103.   Type = MsgNewLine;                   /* new line in message window */
  104.   Put((char *)&Type,1);
  105.   Put((char *)&LineNum,2);             /* write line number */
  106.   Put((char *)&ColNum,2);              /* write column number */
  107.   Put(Message,(int) strlen(Message) + 1);   /* write message */
  108. }
  109.