NO

Author Topic: Error line piping/modifier for example msvc  (Read 3769 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Error line piping/modifier for example msvc
« on: March 17, 2010, 08:43:34 AM »
This error line piping/modifier runs program and change string like 'foo.c(10) :' to 'foo.c(10):' for PellesC IDE.
Insert it to PellesC IDE Tools.

For example MSVC:
Arguments: c:\code\msvc9\bin\cl.exe -c -X -Ic:\code\msvc9\include $(FilePath)
Use Output tab
EDIT:
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma intrinsic(memset)
// cl -GS- -Zl ErrFixMSVC.c -link /SUBSYSTEM:CONSOLE kernel32.lib

int __cdecl mainCRTStartup(void)
{
HANDLE hStdOut, hRead, hWrite;
SECURITY_ATTRIBUTES sa;
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD nRead, nIdx, nPos, nWrite, nExit;
char *lpszCmdLine, *pChar;
char szBuff[1024];
char szLine[1024];

nExit = 0;
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
lpszCmdLine = GetCommandLine();
pChar = lpszCmdLine;
if (*pChar == '"') {
pChar++;
while (*pChar && *pChar != '"')
pChar++;
pChar++;
} else {
while (*pChar && *pChar > ' ')
pChar++;
}
while (*pChar && *pChar <= ' ')
pChar++;

sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (CreatePipe(&hRead, &hWrite, &sa, 0)) {
memset(&si, 0, sizeof(si));
si.cb = sizeof(STARTUPINFO);
//GetStartupInfo(&si);
si.hStdOutput = hWrite;
si.hStdError = hWrite;
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
//si.lpReserved = NULL;
if (CreateProcess(NULL, pChar, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) {
CloseHandle(hWrite);
nPos = 0;
szLine[0] = 0;
while (TRUE) {
szBuff[0] = 0;
if (!ReadFile(hRead, szBuff, sizeof(szBuff)-1, &nRead, NULL))
break;
szBuff[nRead] = 0;
for (nIdx = 0; nIdx < nRead; nIdx++) {
szLine[nPos++] = szBuff[nIdx];
szLine[nPos] = 0;

if (nPos > 3 && szLine[nPos-1] == ':'
&& szLine[nPos-2] == ' ' && szLine[nPos-3] == ')') {
szLine[nPos-2] = ':';
szLine[nPos-1] = ' ';
}

szLine[nPos] = 0;
if (szBuff[nIdx] == 10) {
szLine[nPos] = 0;
//printf(szLine);
WriteFile(hStdOut, szLine, nPos, &nWrite, NULL);
nPos = 0;
szLine[0] = 0;
}
}
}
GetExitCodeProcess(pi.hProcess, &nExit);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
} else {
WriteFile(hStdOut, "Error\r\n", 7, &nWrite, NULL);
nExit = 0;
}
CloseHandle(hRead);
} else { // ERROR
WriteFile(hStdOut, "Error\r\n", 7, &nWrite, NULL);
nExit = 0;
}
ExitProcess(nExit);
return 0;
}
« Last Edit: November 04, 2016, 10:02:50 AM by TimoVJL »
May the source be with you

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Error line piping/modifier for example msvc
« Reply #1 on: August 27, 2011, 11:24:32 AM »
Small fixes only.
I use this to verify that i can compile code with msvc too (DDK version).
May the source be with you