The R Project SVN R

Rev

Rev 45053 | Rev 46084 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 45053 Rev 45475
Line 29... Line 29...
29
*/
29
*/
30
 
30
 
31
/* execv exists and can be used on Windows, but it returns immediately
31
/* execv exists and can be used on Windows, but it returns immediately
32
   and so the exit status is lost.  HAVE_EXECV is defined under Windows.
32
   and so the exit status is lost.  HAVE_EXECV is defined under Windows.
33
 
33
 
34
   The main reason for using execv rather than system is to avoid 
34
   The main reason for using execv rather than system is to avoid
35
   argument quoting hell.
35
   argument quoting hell.
36
*/
36
*/
37
 
37
 
38
#ifdef HAVE_CONFIG_H
38
#ifdef HAVE_CONFIG_H
39
# include <config.h>
39
# include <config.h>
Line 67... Line 67...
67
static char rhome[] = R_HOME;
67
static char rhome[] = R_HOME;
68
#else
68
#else
69
# include "rterm.c"
69
# include "rterm.c"
70
#endif
70
#endif
71
 
71
 
72
#define RSVERSION "$Rev: 45053 $"
72
#define RSVERSION "$Rev: 45475 $"
73
 
73
 
74
#ifdef HAVE_EXECV
74
#ifdef HAVE_EXECV
75
static int verbose = 0;
75
static int verbose = 0;
76
#endif
76
#endif
77
 
77
 
Line 135... Line 135...
135
    sprintf(cmd, "%s/bin/R", p);
135
    sprintf(cmd, "%s/bin/R", p);
136
#endif
136
#endif
137
    av[ac++] = cmd;
137
    av[ac++] = cmd;
138
    av[ac++] = "--slave";
138
    av[ac++] = "--slave";
139
    av[ac++] = "--no-restore";
139
    av[ac++] = "--no-restore";
140
    
140
 
141
    if(argc == 2) {
141
    if(argc == 2) {
142
	if(strcmp(argv[1], "--help") == 0) {
142
	if(strcmp(argv[1], "--help") == 0) {
143
	    usage();
143
	    usage();
144
	    exit(0);
144
	    exit(0);
145
	}
145
	}
Line 149... Line 149...
149
	    buf[strlen(buf) - 2] = '\0';
149
	    buf[strlen(buf) - 2] = '\0';
150
	    fprintf(stderr, "R scripting front-end version %s\n", buf);
150
	    fprintf(stderr, "R scripting front-end version %s\n", buf);
151
	    exit(0);
151
	    exit(0);
152
	}
152
	}
153
    }
153
    }
154
    
154
 
155
    /* first copy over any -e or --foo args */
155
    /* first copy over any -e or --foo args */
156
    for(i = 1; i < argc; i++) {
156
    for(i = 1; i < argc; i++) {
157
	if(strcmp(argv[i], "-e") == 0) {
157
	if(strcmp(argv[i], "-e") == 0) {
158
	    e_mode = 1;
158
	    e_mode = 1;
159
	    av[ac++] = argv[i];
159
	    av[ac++] = argv[i];
Line 179... Line 179...
179
	    }
179
	    }
180
	    sprintf(buf2, "R_DEFAULT_PACKAGES=%s", argv[i]+19);
180
	    sprintf(buf2, "R_DEFAULT_PACKAGES=%s", argv[i]+19);
181
	    if(verbose)
181
	    if(verbose)
182
		fprintf(stderr, "setting '%s'\n", buf2);
182
		fprintf(stderr, "setting '%s'\n", buf2);
183
#ifdef HAVE_PUTENV
183
#ifdef HAVE_PUTENV
184
	    if(putenv(buf2)) 
184
	    if(putenv(buf2))
185
#endif
185
#endif
186
	    {
186
	    {
187
		fprintf(stderr, "unable to set R_DEFAULT_PACKAGES\n");
187
		fprintf(stderr, "unable to set R_DEFAULT_PACKAGES\n");
188
		exit(1);
188
		exit(1);
189
	    }
189
	    }
Line 197... Line 197...
197
    if(!e_mode) {
197
    if(!e_mode) {
198
	if(strlen(argv[++i0]) > PATH_MAX) {
198
	if(strlen(argv[++i0]) > PATH_MAX) {
199
	    fprintf(stderr, "file name is too long\n");
199
	    fprintf(stderr, "file name is too long\n");
200
	    exit(1);
200
	    exit(1);
201
	}
201
	}
202
	sprintf(buf, "--file=%s", argv[i0]); 
202
	sprintf(buf, "--file=%s", argv[i0]);
203
	av[ac++] = buf;
203
	av[ac++] = buf;
204
    }
204
    }
205
    av[ac++] = "--args";
205
    av[ac++] = "--args";
206
    for(i = i0+1; i < argc; i++) av[ac++] = argv[i];
206
    for(i = i0+1; i < argc; i++) av[ac++] = argv[i];
207
    av[ac] = (char *) NULL;
207
    av[ac] = (char *) NULL;