The R Project SVN R

Rev

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

Rev 6153 Rev 6168
Line 35... Line 35...
35
    char *s, *p, *q, *f, *dest, *src;
35
    char *s, *p, *q, *f, *dest, *src;
36
    char  fl[MAX_PATH], fn[MAX_PATH];
36
    char  fl[MAX_PATH], fn[MAX_PATH];
37
    int   d , ext;
37
    int   d , ext;
38
 
38
 
39
    if (!(s = (char *) winmalloc(MAX_PATH + strlen(cmd)))) {
39
    if (!(s = (char *) winmalloc(MAX_PATH + strlen(cmd)))) {
40
	strcpy(RunError, "Insufficient memory (expandcmd)\n");
40
	strcpy(RunError, "Insufficient memory (expandcmd)");
41
	return NULL;
41
	return NULL;
42
    }
42
    }
43
    for (p = cmd; *p && isspace(*p); p++);
43
    for (p = cmd; *p && isspace(*p); p++);
44
    for (q = p, d = 0; *q && ( d || !isspace(*q) ); q++)
44
    for (q = p, d = 0; *q && ( d || !isspace(*q) ); q++)
45
      if (*q=='\"') d = d ? 0 : 1;
45
      if (*q=='\"') d = d ? 0 : 1;
46
    if (d) {
46
    if (d) {
47
	strcpy(RunError, "A \" is missing(expandcmd)\n");
47
	strcpy(RunError, "A \" is missing(expandcmd)");
48
	return NULL;
48
	return NULL;
49
    }
49
    }
50
    c = *q;
50
    c = *q;
51
    *q = '\0';
51
    *q = '\0';
52
    
52
    
Line 79... Line 79...
79
     }
79
     }
80
   }
80
   }
81
   if (!d) {
81
   if (!d) {
82
       winfree(s);
82
       winfree(s);
83
       strncpy(RunError,p, 200);
83
       strncpy(RunError,p, 200);
84
       strcat(RunError," not found \n");
84
       strcat(RunError," not found");
85
       *q = c;
85
       *q = c;
86
       return NULL;
86
       return NULL;
87
   }
87
   }
88
   /* 
88
   /* 
89
      Paranoia : on my system switching to short names is not needed
89
      Paranoia : on my system switching to short names is not needed
Line 169... Line 169...
169
	CloseHandle(si.hStdError);
169
	CloseHandle(si.hStdError);
170
    }
170
    }
171
    if (!ret) {
171
    if (!ret) {
172
	strcpy(RunError, "Impossible to run '");
172
	strcpy(RunError, "Impossible to run '");
173
	strncat(RunError, ecmd, 200);
173
	strncat(RunError, ecmd, 200);
174
	strcat(RunError, "'\n");
-
 
175
	winfree(ecmd);
174
	winfree(ecmd);
176
	return NULL;
175
	return NULL;
177
    }
176
    }
178
    winfree(ecmd);
177
    winfree(ecmd);
179
    CloseHandle(pi.hThread);
178
    CloseHandle(pi.hThread);
Line 230... Line 229...
230
    rpipe *r;
229
    rpipe *r;
231
    HANDLE hOUT, hERR, hThread, hTHIS, hTemp;
230
    HANDLE hOUT, hERR, hThread, hTHIS, hTemp;
232
    DWORD id;
231
    DWORD id;
233
 
232
 
234
    if (!(r = (rpipe *) winmalloc(sizeof(struct structRPIPE)))) {
233
    if (!(r = (rpipe *) winmalloc(sizeof(struct structRPIPE)))) {
235
	strcpy(RunError, "Insufficient memory (rpipeOpen)\n");
234
	strcpy(RunError, "Insufficient memory (rpipeOpen)");
236
	return NULL;
235
	return NULL;
237
    }
236
    }
238
    r->process = NULL;
237
    r->process = NULL;
239
    if (CreatePipe(&hTemp, &(r->write), NULL, 0) == FALSE) {
238
    if (CreatePipe(&hTemp, &(r->write), NULL, 0) == FALSE) {
240
	rpipeClose(r);
239
	rpipeClose(r);
241
	strcpy(RunError, "Inpossible to create pipe\n");
240
	strcpy(RunError, "Inpossible to create pipe");
242
	return NULL;
241
	return NULL;
243
    }
242
    }
244
    hTHIS = GetCurrentProcess();
243
    hTHIS = GetCurrentProcess();
245
    DuplicateHandle(hTHIS, GetStdHandle(STD_OUTPUT_HANDLE), hTHIS, &hOUT,
244
    DuplicateHandle(hTHIS, GetStdHandle(STD_OUTPUT_HANDLE), hTHIS, &hOUT,
246
		    0, FALSE, DUPLICATE_SAME_ACCESS);
245
		    0, FALSE, DUPLICATE_SAME_ACCESS);
Line 258... Line 257...
258
    SetStdHandle(STD_ERROR_HANDLE, hERR);
257
    SetStdHandle(STD_ERROR_HANDLE, hERR);
259
    if (!r->process)
258
    if (!r->process)
260
	return NULL;
259
	return NULL;
261
    if (!(hThread = CreateThread(NULL, 0, threadedwait, r, 0, &id))) {
260
    if (!(hThread = CreateThread(NULL, 0, threadedwait, r, 0, &id))) {
262
	rpipeClose(r);
261
	rpipeClose(r);
263
	strcpy(RunError, "Inpossible to create thread/pipe \n");
262
	strcpy(RunError, "Inpossible to create thread/pipe");
264
	return NULL;
263
	return NULL;
265
    }
264
    }
266
    CloseHandle(hThread);
265
    CloseHandle(hThread);
267
    return r;
266
    return r;
268
}
267
}