Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect uses of feof() #957

Merged
merged 1 commit into from Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions plugins/admin.sma
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions plugins/cmdmenu.sma
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions plugins/cstrike/miscstats.sma
Expand Up @@ -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] != ';' )
{
Expand All @@ -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 )
{
Expand Down
6 changes: 4 additions & 2 deletions plugins/cstrike/restmenu.sma
Expand Up @@ -590,9 +590,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;
}
Expand Down
5 changes: 1 addition & 4 deletions plugins/mapchooser.sma
Expand Up @@ -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));


Expand Down
4 changes: 1 addition & 3 deletions plugins/mapsmenu.sma
Expand Up @@ -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;
Expand Down