Replace do { while (true) ; with for (;;)

This commit is contained in:
libretroadmin 2024-04-05 20:02:36 +02:00
parent 0212d8e770
commit b8d12a7d12
3 changed files with 26 additions and 38 deletions

View File

@ -86,7 +86,7 @@ bool TInputScanner::consumeComment()
// a '//' style comment // a '//' style comment
get(); // consume the second '/' get(); // consume the second '/'
c = get(); c = get();
do { for (;;) {
while (c != EndOfInput && c != '\\' && c != '\r' && c != '\n') while (c != EndOfInput && c != '\\' && c != '\r' && c != '\n')
c = get(); c = get();
@ -107,19 +107,16 @@ bool TInputScanner::consumeComment()
get(); get();
c = get(); c = get();
} }
} while (true); };
// put back the last non-comment character // put back the last non-comment character
if (c != EndOfInput) if (c != EndOfInput)
unget(); unget();
return true;
} else if (c == '*') { } else if (c == '*') {
// a '/*' style comment // a '/*' style comment
get(); // consume the '*' get(); // consume the '*'
c = get(); c = get();
do { for (;;) {
while (c != EndOfInput && c != '*') while (c != EndOfInput && c != '*')
c = get(); c = get();
if (c == '*') { if (c == '*') {
@ -129,21 +126,22 @@ bool TInputScanner::consumeComment()
// not end of comment // not end of comment
} else // end of input } else // end of input
break; break;
} while (true); };
}
return true; else
} else { {
// it's not a comment, put the '/' back // it's not a comment, put the '/' back
unget(); unget();
return false; return false;
} }
return true;
} }
// skip whitespace, then skip a comment, rinse, repeat // skip whitespace, then skip a comment, rinse, repeat
void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab) void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab)
{ {
do { for (;;) {
consumeWhiteSpace(foundNonSpaceTab); consumeWhiteSpace(foundNonSpaceTab);
// if not starting a comment now, then done // if not starting a comment now, then done
@ -153,10 +151,9 @@ void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab)
// skip potential comment // skip potential comment
foundNonSpaceTab = true; foundNonSpaceTab = true;
if (! consumeComment()) if (!consumeComment())
return; return;
};
} while (true);
} }
// Returns true if there was non-white space (e.g., a comment, newline) before the #version // Returns true if there was non-white space (e.g., a comment, newline) before the #version
@ -184,7 +181,7 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile, bool& notFirstT
bool foundNonSpaceTab = false; bool foundNonSpaceTab = false;
bool lookingInMiddle = false; bool lookingInMiddle = false;
int c; int c;
do { for (;;) {
if (lookingInMiddle) { if (lookingInMiddle) {
notFirstToken = true; notFirstToken = true;
// make forward progress by finishing off the current line plus extra new lines // make forward progress by finishing off the current line plus extra new lines
@ -273,7 +270,7 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile, bool& notFirstT
profile = ECompatibilityProfile; profile = ECompatibilityProfile;
return versionNotFirst; return versionNotFirst;
} while (true); };
} }
// Fill this in when doing glslang-level scanning, to hand back to the parser. // Fill this in when doing glslang-level scanning, to hand back to the parser.
@ -723,7 +720,7 @@ void TScanContext::deleteKeywordMap()
// Returning 0 implies end of input. // Returning 0 implies end of input.
int TScanContext::tokenize(TPpContext* pp, TParserToken& token) int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
{ {
do { for (;;) {
parserToken = &token; parserToken = &token;
TPpToken ppToken; TPpToken ppToken;
int token = pp->tokenize(ppToken); int token = pp->tokenize(ppToken);
@ -818,7 +815,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
_parseContext.error(loc, "unexpected token", buf, ""); _parseContext.error(loc, "unexpected token", buf, "");
break; break;
} }
} while (true); };
} }
int TScanContext::tokenizeIdentifier() int TScanContext::tokenizeIdentifier()

View File

@ -89,16 +89,12 @@
*/ */
static const void *MD5_body(MD5_CTX *ctx, const void *data, unsigned long size) static const void *MD5_body(MD5_CTX *ctx, const void *data, unsigned long size)
{ {
const unsigned char *ptr;
MD5_u32plus a, b, c, d;
MD5_u32plus saved_a, saved_b, saved_c, saved_d; MD5_u32plus saved_a, saved_b, saved_c, saved_d;
const unsigned char *ptr = (const unsigned char *)data;
ptr = (const unsigned char *)data; MD5_u32plus a = ctx->a;
MD5_u32plus b = ctx->b;
a = ctx->a; MD5_u32plus c = ctx->c;
b = ctx->b; MD5_u32plus d = ctx->d;
c = ctx->c;
d = ctx->d;
do { do {
saved_a = a; saved_a = a;
@ -207,10 +203,8 @@ void MD5_Init(MD5_CTX *ctx)
void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
{ {
MD5_u32plus saved_lo; unsigned long used;
unsigned long used, available; MD5_u32plus saved_lo = ctx->lo;
saved_lo = ctx->lo;
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
ctx->hi++; ctx->hi++;
ctx->hi += size >> 29; ctx->hi += size >> 29;
@ -219,7 +213,7 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
if (used) if (used)
{ {
available = 64 - used; unsigned long available = 64 - used;
if (size < available) if (size < available)
{ {
@ -244,9 +238,8 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
void MD5_Final(unsigned char *result, MD5_CTX *ctx) void MD5_Final(unsigned char *result, MD5_CTX *ctx)
{ {
unsigned long used, available; unsigned long available;
unsigned long used = ctx->lo & 0x3f;
used = ctx->lo & 0x3f;
ctx->buffer[used++] = 0x80; ctx->buffer[used++] = 0x80;

View File

@ -226,11 +226,9 @@ void SHA1Input( SHA1Context *context,
context->Length_High++; context->Length_High++;
/* Force it to 32 bits */ /* Force it to 32 bits */
context->Length_High &= 0xFFFFFFFF; context->Length_High &= 0xFFFFFFFF;
/* Message is too long */
if (context->Length_High == 0) if (context->Length_High == 0)
{
/* Message is too long */
context->Corrupted = 1; context->Corrupted = 1;
}
} }
if (context->Message_Block_Index == 64) if (context->Message_Block_Index == 64)