The R Project SVN R

Rev

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

Rev 68956 Rev 72455
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
 *  file rt_complete.c
3
 *  file rt_complete.c
4
 *  Copyright (C) 2007-13 The R Core Team.
4
 *  Copyright (C) 2007-2017 The R Core Team.
5
 *
5
 *
6
 *  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
7
 *  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
8
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
9
 *  (at your option) any later version.
Line 88... Line 88...
88
		return -1; /* no change */
88
		return -1; /* no change */
89
	    }
89
	    }
90
	}
90
	}
91
    }
91
    }
92
 
92
 
93
    /* FIXME: need to escape quotes properly */
93
    alen = strlen(partial_line);
94
    char pline[strlen(partial_line) + 1];
94
    char orig[alen + 1], pline[2*alen + 1],
-
 
95
            *pchar = pline, achar;
95
    strcpy(pline, partial_line);
96
    strcpy(orig, partial_line);
96
    /* poor attempt at escaping quotes that sort of works */
97
    for (i = 0; i < alen; i++) {
97
    alen = strlen(pline);
98
        achar = orig[i];
98
    for (i = 0; i < alen; i++) if (pline[i] == '"') pline[i] = '\'';
99
	if (achar == '"' || achar == '\\') *pchar++ = '\\';
-
 
100
	*pchar++ = achar;
99
 
101
    }
-
 
102
    *pchar = 0;
100
    size_t len = strlen(pline) + 100; 
103
    size_t len = strlen(pline) + 100; 
101
    char cmd[len];
104
    char cmd[len];
102
    snprintf(cmd, len,
105
    snprintf(cmd, len,
103
	     "utils:::.win32consoleCompletion(\"%s\", %d)",
106
	     "utils:::.win32consoleCompletion(\"%s\", %d)",
104
	     pline, cursor_position);
107
	     pline, cursor_position);