c++ – Filter out comments in Delphi source code

Today I am working on refactoring and documenting some ancient Delphi code. In that language, which is derived from Pascal, there are three forms of comments:

(* This is the original Pascal style comment, which is never used in my files *)
{ this is TurboPascal-style comment which I want to remove }
// This is a Delphi-style comment which  I want to remove 

As noted in this small sample, I want to strip out the last two styles of comments. The first kind of comment is never used in the code files I’m using, so there is no special processing done if they are encountered. I decided to do this using a std::streambuf. The code and some sample input is below. I’m interested in any comments for improvement.

commentfilterbuf.h

#ifndef COMMENTFILTER_H
#define COMMENTFILTER_H
#include <streambuf>

class commentfilterbuf : public std::streambuf {
    std::streambuf* sbuf;
    char buffer = EOF;
public:
    commentfilterbuf(std::streambuf* sbuf);
    int underflow(); 
};
#endif // COMMENTFILTER_H

commentfilterbuf.cpp

#include "commentfilterbuf.h"

commentfilterbuf::commentfilterbuf(std::streambuf* sbuf)
    : sbuf(sbuf)
{
}

int commentfilterbuf::underflow() {
    traits_type::int_type i;
    // skip comments which are delimited with { and }
    for (i = sbuf->sbumpc(); i == '{'; i = sbuf->sbumpc()) {
        while ((i = sbuf->sbumpc()) != '}');
    }
    if (traits_type::not_eof(i)) {
        // check for single line comments like this one
        if (i == sbuf->sgetc() && i == '/') {
            while ((i = sbuf->sbumpc()) != 'n');
        }
        buffer = traits_type::to_char_type(i);
        setg(&buffer, &buffer, &buffer+1);
    }
    return i;
}

testfilter.cpp

#include "commentfilterbuf.h"
#include <iostream>
#include <fstream>
#include <string>

int main(int argc, char* argv())
{
    if (argc != 2) {
        std::cerr << "Usage: testfilter inputfilen";
        return 0;
    }
    std::ifstream fin{argv(1)};
    if (!fin) {
        std::cerr << "Error: could not open " << argv(1) << "n";
        return 1;
    }
    commentfilterbuf sbuf(fin.rdbuf());
    std::istream in(&sbuf);
    std::string line;
    for (std::string line; std::getline(in, line); ) {
        std::cout << line << 'n';
    }
}

sample.in

program HelloWorld;

{$APPTYPE CONSOLE}
{ This is a comment. }
{
    this is a multiline comment.
}
{  This is a Turbo Pascal comment }  
// This is a Delphi comment. All is ignored till the end of the line.
// let's try to confuse the parser
{ comment 1 // Comment 2 }begin
// comment 1 { comment 2 }foo

  // Here's a comment
  WriteLn('Hello World');  { and another }
end.