(svn r22144) -Codechange: Unify 'while (true)' to 'for (;;)'

This commit is contained in:
alberth 2011-02-25 21:53:43 +00:00
parent c43e818ff2
commit a14f4eb271
11 changed files with 14 additions and 14 deletions

View File

@ -565,7 +565,7 @@ bool ExpressionAnd(Lexer *lexer, StringSet *defines, bool verbose)
{ {
bool value = ExpressionDefined(lexer, defines, verbose); bool value = ExpressionDefined(lexer, defines, verbose);
while (true) { for (;;) {
if (lexer->GetToken() != TOKEN_AND) return value; if (lexer->GetToken() != TOKEN_AND) return value;
if (verbose) fprintf(stderr, " && "); if (verbose) fprintf(stderr, " && ");
lexer->Lex(); lexer->Lex();
@ -584,7 +584,7 @@ bool ExpressionOr(Lexer *lexer, StringSet *defines, bool verbose)
{ {
bool value = ExpressionAnd(lexer, defines, verbose); bool value = ExpressionAnd(lexer, defines, verbose);
while (true) { for (;;) {
if (lexer->GetToken() != TOKEN_OR) return value; if (lexer->GetToken() != TOKEN_OR) return value;
if (verbose) fprintf(stderr, " || "); if (verbose) fprintf(stderr, " || ");
lexer->Lex(); lexer->Lex();

View File

@ -90,7 +90,7 @@ static uint16 ParseKeycode(const char *start, const char *end)
{ {
assert(start <= end); assert(start <= end);
uint16 keycode = 0; uint16 keycode = 0;
while (true) { for (;;) {
const char *cur = start; const char *cur = start;
while (*cur != '+' && cur != end) cur++; while (*cur != '+' && cur != end) cur++;
uint16 code = ParseCode(start, cur); uint16 code = ParseCode(start, cur);

View File

@ -67,7 +67,7 @@ struct CHashTableSlotT
return true; return true;
} }
Titem_ *pItem = m_pFirst; Titem_ *pItem = m_pFirst;
while (true) { for (;;) {
if (pItem == NULL) { if (pItem == NULL) {
return false; return false;
} }

View File

@ -379,7 +379,7 @@ static bool GunzipFile(const ContentInfo *ci)
ret = false; ret = false;
} else { } else {
byte buff[8192]; byte buff[8192];
while (1) { for (;;) {
int read = gzread(fin, buff, sizeof(buff)); int read = gzread(fin, buff, sizeof(buff));
if (read == 0) { if (read == 0) {
/* If gzread() returns 0, either the end-of-file has been /* If gzread() returns 0, either the end-of-file has been

View File

@ -151,7 +151,7 @@ static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool ch
if (check_type) orig_type = GetCustomStationSpecIndex(tile); if (check_type) orig_type = GetCustomStationSpecIndex(tile);
if (check_axis) orig_axis = GetRailStationAxis(tile); if (check_axis) orig_axis = GetRailStationAxis(tile);
while (true) { for (;;) {
TileIndex new_tile = TILE_ADD(tile, delta); TileIndex new_tile = TILE_ADD(tile, delta);
if (!IsTileType(new_tile, MP_STATION) || GetStationIndex(new_tile) != sid) break; if (!IsTileType(new_tile, MP_STATION) || GetStationIndex(new_tile) != sid) break;

View File

@ -130,7 +130,7 @@ public:
Yapf().PfSetStartupNodes(); Yapf().PfSetStartupNodes();
bool bDestFound = true; bool bDestFound = true;
while (true) { for (;;) {
m_num_steps++; m_num_steps++;
Node *n = m_nodes.GetBestOpenNode(); Node *n = m_nodes.GetBestOpenNode();
if (n == NULL) { if (n == NULL) {

View File

@ -107,7 +107,7 @@ public:
/* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */ /* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */
TileIndex tile = n.m_key.m_tile; TileIndex tile = n.m_key.m_tile;
Trackdir trackdir = n.m_key.m_td; Trackdir trackdir = n.m_key.m_td;
while (true) { for (;;) {
/* base tile cost depending on distance between edges */ /* base tile cost depending on distance between edges */
segment_cost += Yapf().OneTileCost(tile, trackdir); segment_cost += Yapf().OneTileCost(tile, trackdir);

View File

@ -761,7 +761,7 @@ int SlIterateArray()
* we must have read in all the data, so we must be at end of current block. */ * we must have read in all the data, so we must be at end of current block. */
if (_next_offs != 0 && _sl.reader->GetSize() != _next_offs) SlErrorCorrupt("Invalid chunk size"); if (_next_offs != 0 && _sl.reader->GetSize() != _next_offs) SlErrorCorrupt("Invalid chunk size");
while (true) { for (;;) {
uint length = SlReadArrayLength(); uint length = SlReadArrayLength();
if (length == 0) { if (length == 0) {
_next_offs = 0; _next_offs = 0;

View File

@ -675,7 +675,7 @@ static char *FormatString(char *buff, const char *str_arg, int64 *argv, const in
std::stack<const char *> str_stack; std::stack<const char *> str_stack;
str_stack.push(str_arg); str_stack.push(str_arg);
while (true) { for (;;) {
while (!str_stack.empty() && (b = Utf8Consume(&str_stack.top())) == '\0') { while (!str_stack.empty() && (b = Utf8Consume(&str_stack.top())) == '\0') {
str_stack.pop(); str_stack.pop();
} }

View File

@ -97,7 +97,7 @@ static void WINAPI CheckForConsoleInput()
#else #else
DWORD nb; DWORD nb;
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
while (true) { for (;;) {
ReadFile(hStdin, _win_console_thread_buffer, lengthof(_win_console_thread_buffer), &nb, NULL); ReadFile(hStdin, _win_console_thread_buffer, lengthof(_win_console_thread_buffer), &nb, NULL);
/* Signal input waiting that input is read and wait for it being handled /* Signal input waiting that input is read and wait for it being handled
* SignalObjectAndWait() should be used here, but it's unsupported in Win98< */ * SignalObjectAndWait() should be used here, but it's unsupported in Win98< */

View File

@ -1061,7 +1061,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array)
/* 1b. Make the container higher if needed to accomadate all childs nicely. */ /* 1b. Make the container higher if needed to accomadate all childs nicely. */
uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height. uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height.
uint cur_height = this->smallest_y; uint cur_height = this->smallest_y;
while (true) { for (;;) {
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) { for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
uint step_size = child_wid->GetVerticalStepSize(ST_SMALLEST); uint step_size = child_wid->GetVerticalStepSize(ST_SMALLEST);
uint child_height = child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom; uint child_height = child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom;
@ -1213,7 +1213,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array)
/* 1b. Make the container wider if needed to accomadate all childs nicely. */ /* 1b. Make the container wider if needed to accomadate all childs nicely. */
uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height. uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height.
uint cur_width = this->smallest_x; uint cur_width = this->smallest_x;
while (true) { for (;;) {
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) { for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
uint step_size = child_wid->GetHorizontalStepSize(ST_SMALLEST); uint step_size = child_wid->GetHorizontalStepSize(ST_SMALLEST);
uint child_width = child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right; uint child_width = child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right;
@ -2538,7 +2538,7 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase **par
assert(*parent == NULL || (nwid_cont != NULL && nwid_parent == NULL) || (nwid_cont == NULL && nwid_parent != NULL)); assert(*parent == NULL || (nwid_cont != NULL && nwid_parent == NULL) || (nwid_cont == NULL && nwid_parent != NULL));
int total_used = 0; int total_used = 0;
while (true) { for (;;) {
NWidgetBase *sub_widget = NULL; NWidgetBase *sub_widget = NULL;
bool fill_sub = false; bool fill_sub = false;
int num_used = MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index); int num_used = MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index);