Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 403
    • Issues 403
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2194
Closed
Open
Created Feb 22, 2012 by Bep Rinto@broGuest

fclose crashes

Bugzilla Link 915
Created on Feb 22, 2012 10:49
Resolution FIXED
Resolved on Mar 01, 2012 19:01
Version svn
OS Linux
Architecture PC

Extended Description

There's a bug with fclose.c for
sac2c-1.00-17729-beta-linux-i386.tar.gz
It expects a two star pointer
while SAC only gives it a one.
Fix in stdlib/world/stdio/src/File/fclose.c:
// bug in SAC: void SACfclose(FILE **stream)
// fix is here below:
void SACfclose(FILE *stream)
{
...
}
Use this SAC file for testing stdio:
use File:         { File, fopen, fclose, fseek, ftell, rewind };
use RuntimeError: { error };
use CommandLine:  { argc, argv };
use SysErr:       { fail };
import ScalarArith: all;
int main()
{
    if (argc() < 2) {
        error(1, "Need at least one file arg");
    }
    for (i = 1; i < argc(); ++i) {
        name = argv(i);
        err, fp = fopen( name, "r");
        if (fail(err)) {
            if ( SysErr::fail(err) == true) {
                error( (:int)err, "Failed to open %s for reading", name);
            }
        } else {
            fseek(fp, 0, 2);
            size = ftell(fp);
            rewind(fp);
            fclose(fp);
        }
    }
    return 0;
}
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking