MCPcopy Create free account
hub / github.com/crawl/crawl / _get_version_changes

Function _get_version_changes

crawl-ref/source/command.cc:147–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147static string _get_version_changes()
148{
149 // Attempts to print "Highlights" of the latest version.
150 FILE* fp = fopen_u(datafile_path("changelog.txt", false).c_str(), "r");
151 if (!fp)
152 return "";
153
154 string result = "";
155 string help;
156 char buf[200];
157 bool start = false;
158 while (fgets(buf, sizeof buf, fp))
159 {
160 // Remove trailing spaces.
161 for (int i = strlen(buf) - 1; i >= 0; i++)
162 {
163 if (isspace(buf[i]))
164 buf[i] = 0;
165 else
166 break;
167 }
168 help = buf;
169
170 // Look for version headings
171 if (starts_with(help, "Stone Soup "))
172 {
173 // Stop if this is for an older major version; otherwise, highlight
174 if (help.find(string("Stone Soup ")+Version::Major) == string::npos)
175 break;
176 else
177 goto highlight;
178 }
179
180 if (help.find("Highlights") != string::npos)
181 {
182 highlight:
183 // Highlight the Highlights, so to speak.
184 result += "<w>" + help + "</w>\n";
185 // And start printing from now on.
186 start = true;
187 }
188 else if (!start)
189 continue;
190 else
191 {
192 result += buf;
193 result += "\n";
194 }
195 }
196 fclose(fp);
197
198 // Did we ever get to print the Highlights?
199 if (start)
200 {
201 result.erase(1+result.find_last_not_of('\n'));
202 result += "\n\n";
203 result += "For earlier changes, see changelog.txt "
204 "in the docs/ directory.";

Callers 1

_print_versionFunction · 0.85

Calls 5

fopen_uFunction · 0.85
datafile_pathFunction · 0.85
starts_withFunction · 0.85
findMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected