The R Project SVN R

Rev

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

Rev 62045 Rev 62580
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) 2006-10  The R Core Team
3
 *  Copyright (C) 2006-13  The R Core Team
4
 *
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
5
 *  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
6
 *  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
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
Line 145... Line 145...
145
    /* avoid snprintf here */
145
    /* avoid snprintf here */
146
    if(strlen(p) + 6 > PATH_MAX) {
146
    if(strlen(p) + 6 > PATH_MAX) {
147
	fprintf(stderr, "impossibly long path for RHOME\n");
147
	fprintf(stderr, "impossibly long path for RHOME\n");
148
	exit(1);
148
	exit(1);
149
    }
149
    }
150
    sprintf(cmd, "%s/bin/R", p);
150
    snprintf(cmd, PATH_MAX+1, "%s/bin/R", p);
151
#endif
151
#endif
152
    av[ac++] = cmd;
152
    av[ac++] = cmd;
153
    av[ac++] = "--slave";
153
    av[ac++] = "--slave";
154
    av[ac++] = "--no-restore";
154
    av[ac++] = "--no-restore";
155
 
155
 
Line 193... Line 193...
193
	    set_dp = 1;
193
	    set_dp = 1;
194
	    if(strlen(argv[i]) > 1000) {
194
	    if(strlen(argv[i]) > 1000) {
195
		fprintf(stderr, "unable to set R_DEFAULT_PACKAGES\n");
195
		fprintf(stderr, "unable to set R_DEFAULT_PACKAGES\n");
196
		exit(1);
196
		exit(1);
197
	    }
197
	    }
198
	    sprintf(buf2, "R_DEFAULT_PACKAGES=%s", argv[i]+19);
198
	    snprintf(buf2, 1100, "R_DEFAULT_PACKAGES=%s", argv[i]+19);
199
	    if(verbose)
199
	    if(verbose)
200
		fprintf(stderr, "setting '%s'\n", buf2);
200
		fprintf(stderr, "setting '%s'\n", buf2);
201
#ifdef HAVE_PUTENV
201
#ifdef HAVE_PUTENV
202
	    if(putenv(buf2))
202
	    if(putenv(buf2))
203
#endif
203
#endif
Line 211... Line 211...
211
	av[ac++] = argv[i];
211
	av[ac++] = argv[i];
212
	i0 = i;
212
	i0 = i;
213
    }
213
    }
214
 
214
 
215
    if(!e_mode) {
215
    if(!e_mode) {
216
      if(++i0 >= argc) {
216
	if(++i0 >= argc) {
217
        fprintf(stderr, "file name is missing\n");
217
	    fprintf(stderr, "file name is missing\n");
218
        exit(1);
218
	    exit(1);
219
      }
219
	}
220
      if(strlen(argv[i0]) > PATH_MAX) {
220
	if(strlen(argv[i0]) > PATH_MAX) {
221
	    fprintf(stderr, "file name is too long\n");
221
	    fprintf(stderr, "file name is too long\n");
222
	    exit(1);
222
	    exit(1);
223
	}
223
	}
224
	sprintf(buf, "--file=%s", argv[i0]);
224
	snprintf(buf, PATH_MAX+8, "--file=%s", argv[i0]);
225
	av[ac++] = buf;
225
	av[ac++] = buf;
226
    }
226
    }
227
    av[ac++] = "--args";
227
    av[ac++] = "--args";
228
    for(i = i0+1; i < argc; i++) av[ac++] = argv[i];
228
    for(i = i0+1; i < argc; i++) av[ac++] = argv[i];
229
    av[ac] = (char *) NULL;
229
    av[ac] = (char *) NULL;