The R Project SVN R

Rev

Rev 68956 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68956 Rev 83695
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1998--2007  Guido Masarotto and Brian Ripley
3
 *  Copyright (C) 1998--2007  Guido Masarotto and Brian Ripley
-
 
4
 *            (C) 2023        The R Core Team
4
 *
5
 *
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
7
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
9
 *  (at your option) any later version.
Line 24... Line 25...
24
#include <stdio.h>
25
#include <stdio.h>
25
#include <stdlib.h>
26
#include <stdlib.h>
26
#include <string.h>
27
#include <string.h>
27
#include <Fileio.h>
28
#include <Fileio.h>
28
 
29
 
29
#ifndef MAX_PATH
-
 
30
# include <windows.h>
-
 
31
#endif
-
 
32
 
-
 
33
 
-
 
34
static FILE *ff = NULL;
30
static FILE *ff = NULL;
35
static char optfl[MAX_PATH];
31
static char *optfl = NULL;
36
static int optln;
32
static int optln;
37
 
33
 
38
void optclosefile(void)
34
void optclosefile(void)
39
{
35
{
40
    if (!ff) return;
36
    if (!ff) return;
41
    fclose(ff);
37
    fclose(ff);
42
    ff = NULL;
38
    ff = NULL;
-
 
39
    if (optfl) {
-
 
40
	free(optfl);
-
 
41
	optfl = NULL;
-
 
42
   } 
43
}
43
}
44
 
44
 
45
 
45
 
46
int optopenfile(const char *fname)
46
int optopenfile(const char *fname)
47
{
47
{
48
    optclosefile();
48
    optclosefile();
49
    if (!fname || !(ff = R_fopen(fname,"r"))) return 0;
49
    if (!fname || !(ff = R_fopen(fname,"r"))) return 0;
-
 
50
    optfl = (char *) malloc(strlen(fname) + 1);
-
 
51
    if (!optfl) return 0;
50
    strcpy(optfl,fname);
52
    strcpy(optfl,fname);
51
    optln = 0;
53
    optln = 0;
52
    return 1;
54
    return 1;
53
}
55
}
54
 
56
 
Line 120... Line 122...
120
    else if (strlen(opt[0]))
122
    else if (strlen(opt[0]))
121
	return 3;
123
	return 3;
122
    else
124
    else
123
	return 1;
125
	return 1;
124
}
126
}
-
 
127