-
Allocating "from the back" of MMU-size pages is a good idea.
Anyways, I spent a few moments hacking up a C++ variant:
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char **argv)
{
ifstream fin;
ofstream fout;
if (argc > 1)
fin.open(*++argv);
if (argc > 2)
fout.open(*++argv);
if (fin && fout)
{
do {
char buffer[1000];
char *p;
char *s;
while(fin.getline(s = buffer, sizeof(buffer)-1, '\n'))
{
p = s;
while(p = strchr(s, 'w'))
{
s = p+1;
if ((p - buffer > 2) &&
(p[-1] == 'o') && (p[-2] == 'l') &&
(p[-3] == 'f') && (p[1] == 'o') &&
(p[2] == 'r') && (p[1] = 'e'));
}
fout << buffer << endl;
}
} while(fin);
}
else
{
cout << "Could not open input files" << endl;
return 1;
}
return 0;
}
--
Mats