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:
Fysiks
2021-08-07 10:28:35 -05:00
committed by GitHub
parent 6c9c37eb45
commit 5b1b844184
6 changed files with 10 additions and 19 deletions

View File

@ -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 )
{

View File

@ -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;
}