Source file: /~heha/hs/gccfilt.zip/gccfilt.cpp

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if _MSC_VER >= 1400
#undef stdin
#undef stdout
#undef stderr
extern "C" _CRTIMP extern FILE _iob[];
#define stdin	_iob
#define stdout	(_iob+1)
#define stderr	(_iob+2)
#endif

int strins(char*s,const char*insert) {
 int len=strlen(insert);
 int slen=strlen(s);
 memmove(s+len,s,slen+1);
 memmove(s,insert,len);
 return slen+len;
}

bool digitsbetween(char*p1,char*p2) {
 strtoul(p1+1,&p1,10);
 return p1==p2;
}

void mainCRTStartup() {
 char line[320];
 while (fgets(line,sizeof line-4,stdin)) {
  char*p1,*p2;
  p1=strchr(line,':');
  if (!p1) goto ex;
  p2=strchr(p1+1,':');
  if (!p2) goto ex;
  if (*line=='/') goto abs;
  if (p1-line<2) {	// possibly a drive letter
   if (!digitsbetween(p1,p2)) {		// can be a file name
    p1=p2;
    p2=strchr(p1+1,':');
    if (!p2) goto ex;
    if (!digitsbetween(p1,p2)) goto ex;
    goto abs;
   }
  }
  if (!digitsbetween(p1,p2)) goto ex;
  strins(line,"./");
  p1+=2;
  p2+=2;
abs:
  *p1='(';
  strins(p2,") ");
  for (p2=line;;++p2) {
   p2=strchr(p2,'/');
   if (!p2 || int(p2-p1)>=0) break;
   *p2='\\';
  }
ex:
  fputs(line,stdout);
 }
}
Detected encoding: ASCII (7 bit)2