| Line 819... |
Line 819... |
| 819 |
{
|
819 |
{
|
| 820 |
static char msg[5000];
|
820 |
static char msg[5000];
|
| 821 |
char msg0[] =
|
821 |
char msg0[] =
|
| 822 |
"Start R, a system for statistical computation and graphics, with the\nspecified options\n\nEnvVars: Environmental variables can be set by NAME=value strings\n\nOptions:\n -h, --help Print usage message and exit\n --version Print version info and exit\n --encoding=enc Specify encoding to be used for stdin\n --encoding enc ditto\n --save Do save workspace at the end of the session\n --no-save Don't save it\n",
|
822 |
"Start R, a system for statistical computation and graphics, with the\nspecified options\n\nEnvVars: Environmental variables can be set by NAME=value strings\n\nOptions:\n -h, --help Print usage message and exit\n --version Print version info and exit\n --encoding=enc Specify encoding to be used for stdin\n --encoding enc ditto\n --save Do save workspace at the end of the session\n --no-save Don't save it\n",
|
| 823 |
msg1[] =
|
823 |
msg1[] =
|
| 824 |
" --no-environ Don't read the site and user environment files\n --no-site-file Don't read the site-wide Rprofile\n --no-init-file Don't read the .Rprofile or ~/.Rprofile files\n --restore Do restore previously saved objects at startup\n --no-restore-data Don't restore previously saved objects\n --no-restore-history Don't restore the R history file\n --no-restore Don't restore anything\n",
|
824 |
" --no-environ Don't read the site and user environment files\n --no-site-file Don't read the site-wide Rprofile\n --no-init-file Don't read the .Rprofile or ~/.Rprofile files\n --restore Do restore previously saved objects at startup\n --no-restore-data Don't restore previously saved objects\n --no-restore-history Don't restore the R history file\n --no-restore Don't restore anything\n --workspace=file Workspace to be restored\n",
|
| 825 |
msg2[] =
|
825 |
msg2[] =
|
| 826 |
" --vanilla Combine --no-save, --no-restore, --no-site-file,\n --no-init-file and --no-environ\n",
|
826 |
" --vanilla Combine --no-save, --no-restore, --no-site-file,\n --no-init-file and --no-environ\n",
|
| 827 |
msg2b[] =
|
827 |
msg2b[] =
|
| 828 |
" --max-mem-size=N Set limit for memory to be used by R\n --max-ppsize=N Set max size of protect stack to N\n",
|
828 |
" --max-mem-size=N Set limit for memory to be used by R\n --max-ppsize=N Set max size of protect stack to N\n",
|
| 829 |
msg3[] =
|
829 |
msg3[] =
|
| 830 |
" -q, --quiet Don't print startup message\n --silent Same as --quiet\n --no-echo Make R run as quietly as possible\n --verbose Print more information about progress\n --args Skip the rest of the command line\n",
|
830 |
" -q, --quiet Don't print startup message\n --silent Same as --quiet\n --no-echo Make R run as quietly as possible\n --verbose Print more information about progress\n --args Skip the rest of the command line\n",
|
| 831 |
msg4[] =
|
831 |
msg4[] =
|
| 832 |
" --ess Don't use getline for command-line editing\n and assert interactive use\n -f file Take input from 'file'\n --file=file ditto\n -e expression Use 'expression' as input\n\nOne or more -e options can be used, but not together with -f or --file\n",
|
832 |
" --ess Don't use getline for command-line editing\n and assert interactive use\n -f file Take input from 'file'\n --file=file ditto\n -e expression Use 'expression' as input\n\nOne or more -e options can be used, but not together with -f or --file\n",
|
| 833 |
msg5[] = "\nAn argument ending in .RData (in any case) is taken as the path\nto the workspace to be restored (and implies --restore)";
|
833 |
msg5[] = "\nAn argument ending in .RData (in any case) is taken as the path\nto the workspace to be restored (and implies --restore)";
|
| 834 |
if(CharacterMode == RTerm)
|
834 |
if(CharacterMode == RTerm)
|
| 835 |
strcpy(msg, "Usage: Rterm [options] [< infile] [> outfile] [EnvVars]\n\n");
|
835 |
strcpy(msg, "Usage: Rterm [options] [< infile] [> outfile] [EnvVars]\n\n");
|
| Line 875... |
Line 875... |
| 875 |
isdir &= (access(path, W_OK) == 0);
|
875 |
isdir &= (access(path, W_OK) == 0);
|
| 876 |
}
|
876 |
}
|
| 877 |
return isdir;
|
877 |
return isdir;
|
| 878 |
}
|
878 |
}
|
| 879 |
|
879 |
|
| - |
|
880 |
static Rboolean use_workspace(Rstart Rp, char *name, Rboolean usedRdata)
|
| - |
|
881 |
{
|
| - |
|
882 |
char s[1024];
|
| - |
|
883 |
char path[MAX_PATH];
|
| - |
|
884 |
char *p;
|
| - |
|
885 |
|
| - |
|
886 |
if(!usedRdata) {
|
| - |
|
887 |
if (strlen(name) >= MAX_PATH) {
|
| - |
|
888 |
/* if generated by Windows it must fit */
|
| - |
|
889 |
snprintf(s, 1024, _("Workspace name '%s' is too long\n"), name);
|
| - |
|
890 |
R_ShowMessage(s);
|
| - |
|
891 |
} else {
|
| - |
|
892 |
set_workspace_name(name);
|
| - |
|
893 |
strcpy(path, name);
|
| - |
|
894 |
for (p = path; *p; p++) if (*p == '\\') *p = '/';
|
| - |
|
895 |
p = Rf_strrchr(path, '/');
|
| - |
|
896 |
if(p) {
|
| - |
|
897 |
*p = '\0';
|
| - |
|
898 |
chdir(path);
|
| - |
|
899 |
}
|
| - |
|
900 |
usedRdata = TRUE;
|
| - |
|
901 |
Rp->RestoreAction = SA_RESTORE;
|
| - |
|
902 |
return TRUE;
|
| - |
|
903 |
}
|
| - |
|
904 |
} else {
|
| - |
|
905 |
snprintf(s, 1024, _("ARGUMENT '%s' __ignored__\n"), name);
|
| - |
|
906 |
R_ShowMessage(s);
|
| - |
|
907 |
}
|
| - |
|
908 |
return FALSE;
|
| - |
|
909 |
}
|
| - |
|
910 |
|
| 880 |
int cmdlineoptions(int ac, char **av)
|
911 |
int cmdlineoptions(int ac, char **av)
|
| 881 |
{
|
912 |
{
|
| 882 |
int i, ierr;
|
913 |
int i, ierr;
|
| 883 |
R_size_t value;
|
914 |
R_size_t value;
|
| 884 |
char *p;
|
915 |
char *p;
|
| Line 1119... |
Line 1150... |
| 1119 |
_("cannot open file '%s': %s"),
|
1150 |
_("cannot open file '%s': %s"),
|
| 1120 |
(*av)+7, strerror(errno));
|
1151 |
(*av)+7, strerror(errno));
|
| 1121 |
R_Suicide(s);
|
1152 |
R_Suicide(s);
|
| 1122 |
}
|
1153 |
}
|
| 1123 |
}
|
1154 |
}
|
| - |
|
1155 |
} else if (!strncmp(*av, "--workspace=", 12)) {
|
| - |
|
1156 |
usedRdata = use_workspace(Rp, *av + 12, usedRdata);
|
| 1124 |
} else if(CharacterMode == RTerm && !strcmp(*av, "-e")) {
|
1157 |
} else if(CharacterMode == RTerm && !strcmp(*av, "-e")) {
|
| 1125 |
ac--; av++;
|
1158 |
ac--; av++;
|
| 1126 |
if (!ac || !strlen(*av)) {
|
1159 |
if (!ac || !strlen(*av)) {
|
| 1127 |
snprintf(s, 1024,
|
1160 |
snprintf(s, 1024,
|
| 1128 |
_("option '%s' requires a non-empty argument"),
|
1161 |
_("option '%s' requires a non-empty argument"),
|
| Line 1141... |
Line 1174... |
| 1141 |
R_ShowMessage(s);
|
1174 |
R_ShowMessage(s);
|
| 1142 |
}
|
1175 |
}
|
| 1143 |
} else {
|
1176 |
} else {
|
| 1144 |
/* Look for *.RData, as given by drag-and-drop
|
1177 |
/* Look for *.RData, as given by drag-and-drop
|
| 1145 |
and file association */
|
1178 |
and file association */
|
| 1146 |
char path[MAX_PATH];
|
- |
|
| 1147 |
|
1179 |
|
| 1148 |
if(!usedRdata &&
|
- |
|
| 1149 |
strlen(*av) >= 6 &&
|
- |
|
| 1150 |
stricmp(*av+strlen(*av)-6, ".RData") == 0) {
|
1180 |
if (strlen(*av) >= 6 && stricmp(*av+strlen(*av)-6, ".RData") == 0)
|
| 1151 |
set_workspace_name(*av);
|
1181 |
usedRdata = use_workspace(Rp, *av, usedRdata);
|
| 1152 |
strcpy(path, *av); /* this was generated by Windows so must fit */
|
- |
|
| 1153 |
for (p = path; *p; p++) if (*p == '\\') *p = '/';
|
- |
|
| 1154 |
p = Rf_strrchr(path, '/');
|
- |
|
| 1155 |
if(p) {
|
- |
|
| 1156 |
*p = '\0';
|
- |
|
| 1157 |
chdir(path);
|
- |
|
| 1158 |
}
|
- |
|
| 1159 |
usedRdata = TRUE;
|
- |
|
| 1160 |
Rp->RestoreAction = SA_RESTORE;
|
- |
|
| 1161 |
} else {
|
- |
|
| 1162 |
snprintf(s, 1024, _("ARGUMENT '%s' __ignored__\n"), *av);
|
- |
|
| 1163 |
R_ShowMessage(s);
|
- |
|
| 1164 |
}
|
- |
|
| 1165 |
}
|
1182 |
}
|
| 1166 |
}
|
1183 |
}
|
| 1167 |
if(strlen(cmdlines)) {
|
1184 |
if(strlen(cmdlines)) {
|
| 1168 |
if(ifp) R_Suicide(_("cannot use -e with -f or --file"));
|
1185 |
if(ifp) R_Suicide(_("cannot use -e with -f or --file"));
|
| 1169 |
Rp->R_Interactive = FALSE;
|
1186 |
Rp->R_Interactive = FALSE;
|