The R Project SVN R-packages

Rev

Rev 4590 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4590 Rev 4798
Line 7... Line 7...
7
#include "Rinternals.h"
7
#include "Rinternals.h"
8
 
8
 
9
#define __UTIL__
9
#define __UTIL__
10
#include "sqlite_dataframe.h"
10
#include "sqlite_dataframe.h"
11
 
11
 
12
int _is_r_sym(char *sym) {
12
int _is_r_sym(const char *sym) {
13
    int i, len = strlen(sym);
13
    int i, len = strlen(sym);
14
 
14
 
15
    if (isalpha(sym[0]) || sym[0] == '_') i = 1;
15
    if (isalpha(sym[0]) || sym[0] == '_') i = 1;
16
    else if (sym[0] == '.') { if (isdigit(sym[1])) return FALSE; i = 2; }
16
    else if (sym[0] == '.') { if (isdigit(sym[1])) return FALSE; i = 2; }
17
    else return FALSE;
17
    else return FALSE;
Line 113... Line 113...
113
    sqlite3_finalize(stmt);
113
    sqlite3_finalize(stmt);
114
    return ret;
114
    return ret;
115
}
115
}
116
 
116
 
117
/* TODO: windows version */
117
/* TODO: windows version */
118
char *_get_full_pathname2(char *relpath) {
118
char *_get_full_pathname2(const char *relpath) {
119
    char *tmp1, *tmp2, tmp3, tmp4;
119
    char *tmp1, *tmp2, tmp3, tmp4;
120
    int buflen, relpathlen;
120
    int buflen, relpathlen;
121
 
121
 
122
    relpathlen = strlen(relpath);
122
    relpathlen = strlen(relpath);
123
    if (relpath[0] == '/') {
123
    if (relpath[0] == '/') {
Line 136... Line 136...
136
            }
136
            }
137
        }
137
        }
138
    }
138
    }
139
 
139
 
140
    /* we'll go along the relpath string "normalizing" relative paths */
140
    /* we'll go along the relpath string "normalizing" relative paths */
141
    tmp1 = relpath;
141
    tmp1 = strcpy(g_sql_buf[3], relpath);
142
    while (tmp1[0]) {
142
    while (tmp1[0]) {
143
        tmp2 = tmp1;
143
        tmp2 = tmp1;
144
        while(!(*tmp2 == '/' || *tmp2 == 0)) tmp2++;
144
        while(!(*tmp2 == '/' || *tmp2 == 0)) tmp2++;
145
        
145
        
146
        tmp3 = *tmp2;
146
        tmp3 = *tmp2;
Line 171... Line 171...
171
 
171
 
172
    return g_sql_buf[2];
172
    return g_sql_buf[2];
173
}
173
}
174
 
174
 
175
/* based on p70 of R-exts.pdf */
175
/* based on p70 of R-exts.pdf */
176
SEXP _getListElement(SEXP list, char *varname) {
176
SEXP _getListElement(SEXP list, const char *varname) {
177
    SEXP ret = R_NilValue, names = GET_NAMES(list);
177
    SEXP ret = R_NilValue, names = GET_NAMES(list);
178
    int i;
178
    int i;
179
 
179
 
180
    for (i = 0; i < LENGTH(list); i++) {
180
    for (i = 0; i < LENGTH(list); i++) {
181
        if (strcmp(CHAR(STRING_ELT(names, i)), varname) == 0) {
181
        if (strcmp(CHAR(STRING_ELT(names, i)), varname) == 0) {