src2html: substr doesn't modify std::string, but erase does (nw)

This commit is contained in:
AJR 2019-09-06 19:33:39 -04:00
parent 052b070a85
commit 18cbb7d521

View File

@ -297,8 +297,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "Template is missing a <!--CONTENT--> marker\n"); fprintf(stderr, "Template is missing a <!--CONTENT--> marker\n");
return 1; return 1;
} }
tempfooter.assign(tempheader).substr(result + 14, -1); tempfooter.assign(tempheader).erase(0, result + 14);
tempheader.substr(0, result); tempheader.erase(result);
// recurse over subdirectories // recurse over subdirectories
return recurse_dir(srcdir.length(), dstdir.length(), srcdir, dstdir, tempheader, tempfooter); return recurse_dir(srcdir.length(), dstdir.length(), srcdir, dstdir, tempheader, tempfooter);
@ -849,7 +849,7 @@ static bool find_include_file(std::string &srcincpath, int srcrootlen, int dstro
{ {
sepindex = srcincpath.find_last_of(PATH_SEPARATOR[0]); sepindex = srcincpath.find_last_of(PATH_SEPARATOR[0]);
if (sepindex != -1) if (sepindex != -1)
srcincpath.substr(0, sepindex); srcincpath.erase(sepindex);
} }
// otherwise, append a path separator and the pathpart // otherwise, append a path separator and the pathpart
@ -892,7 +892,7 @@ static bool find_include_file(std::string &srcincpath, int srcrootlen, int dstro
// for each directory left in the filename, we need to prepend a "../" // for each directory left in the filename, we need to prepend a "../"
while ((sepindex = tempfile.find_first_of(PATH_SEPARATOR[0])) != -1) while ((sepindex = tempfile.find_first_of(PATH_SEPARATOR[0])) != -1)
{ {
tempfile.substr(sepindex + 1, -1); tempfile.erase(0, sepindex + 1);
srcincpath.insert(0, "../"); srcincpath.insert(0, "../");
} }
srcincpath.append(".html"); srcincpath.append(".html");