Fix incorrect uses of feof() (#957)
Using feof() as the while loop condition for detecting the end of the file is incorrect.
This commit is contained in:
parent
6c9c37eb45
commit
5b1b844184
@ -364,10 +364,8 @@ loadSettings(szFilename[])
|
||||
new AuthData[44];
|
||||
new Password[32];
|
||||
|
||||
while (!feof(File))
|
||||
while (fgets(File, Text, charsmax(Text)))
|
||||
{
|
||||
fgets(File, Text, charsmax(Text));
|
||||
|
||||
trim(Text);
|
||||
|
||||
// comment
|
||||
|
@ -124,10 +124,8 @@ public plugin_precache( )
|
||||
new fieldNums = 0;
|
||||
new const voxIdent[] = "vox", fvoxIdent[] = "fvox", barneyIdent[] = "barney", hgruntIdent[] = "hgrunt";
|
||||
|
||||
while ( line < MAX_CMDS && ! feof( fp ) ) // Loop till MAX_CMDS or EOF
|
||||
while ( line < MAX_CMDS && fgets( fp, szText, charsmax(szText) ) ) // Loop till MAX_CMDS or no more file data
|
||||
{
|
||||
fgets( fp, szText, charsmax(szText) ); // Store line content
|
||||
|
||||
/* Strips newline */
|
||||
new len = strlen( szText );
|
||||
if ( len != 0 && szText[len-1] == '^n' ) // len != 0 because if the last line of the file is empty, there's no newline
|
||||
|
@ -236,9 +236,8 @@ public plugin_precache()
|
||||
if( fp )
|
||||
{
|
||||
new xvarname[32], xvarid
|
||||
while( !feof(fp) )
|
||||
while( fgets(fp, buffer, charsmax(buffer)) )
|
||||
{
|
||||
fgets(fp, buffer, charsmax(buffer))
|
||||
trim(buffer)
|
||||
if( buffer[0] != ';' )
|
||||
{
|
||||
@ -257,9 +256,8 @@ public plugin_precache()
|
||||
if( fp )
|
||||
{
|
||||
new szSoundKey[32], szSoundFile[SOUNDFILE_PATH_MAXLEN]
|
||||
while( !feof(fp) )
|
||||
while( fgets(fp, buffer, charsmax(buffer)) )
|
||||
{
|
||||
fgets(fp, buffer, charsmax(buffer))
|
||||
trim(buffer)
|
||||
if( buffer[0] != ';' && parse(buffer, szSoundKey, charsmax(szSoundKey), szSoundFile, charsmax(szSoundFile)) == 2 )
|
||||
{
|
||||
|
@ -594,9 +594,11 @@ bool:loadSettings(const filename[])
|
||||
arrayset(RestrictedBotEquipAmmos, '0', charsmax(RestrictedBotEquipAmmos));
|
||||
arrayset(RestrictedBotWeapons, '0', charsmax(RestrictedBotWeapons));
|
||||
|
||||
while (!feof(fp))
|
||||
while (fgets(fp, lineRead, charsmax(lineRead)))
|
||||
{
|
||||
if (fgets(fp, lineRead, charsmax(lineRead)) - trim(lineRead) <= 0)
|
||||
trim(lineRead)
|
||||
|
||||
if (!lineRead[0])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -249,13 +249,10 @@ loadSettings(filename[])
|
||||
|
||||
new fp=fopen(filename,"r");
|
||||
|
||||
while (!feof(fp))
|
||||
while (fgets(fp, buff, charsmax(buff)))
|
||||
{
|
||||
buff[0]='^0';
|
||||
szText[0]='^0';
|
||||
|
||||
fgets(fp, buff, charsmax(buff));
|
||||
|
||||
parse(buff, szText, charsmax(szText));
|
||||
|
||||
|
||||
|
@ -549,10 +549,8 @@ load_settings(filename[])
|
||||
new text[256];
|
||||
new tempMap[32];
|
||||
|
||||
while (!feof(fp))
|
||||
while (fgets(fp, text, charsmax(text)))
|
||||
{
|
||||
fgets(fp, text, charsmax(text));
|
||||
|
||||
if (text[0] == ';')
|
||||
{
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user