The R Project SVN R

Rev

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

Rev 42414 Rev 43389
Line 74... Line 74...
74
    case STRSXP:
74
    case STRSXP:
75
	nx = length(x);
75
	nx = length(x);
76
	names = getAttrib(x, R_NamesSymbol);
76
	names = getAttrib(x, R_NamesSymbol);
77
	if (names != R_NilValue) {
77
	if (names != R_NilValue) {
78
	    /* Try for exact match */
78
	    /* Try for exact match */
79
	    for (i = 0; i < nx; i++)
79
	    for (i = 0; i < nx; i++) {
80
		if (streql(translateChar(STRING_ELT(names, i)),
80
		const char *tmp = translateChar(STRING_ELT(names, i));
-
 
81
		if (!tmp[0]) continue;
81
			   translateChar(STRING_ELT(s, pos)))) {
82
		if (streql(tmp, translateChar(STRING_ELT(s, pos)))) {
82
		    indx = i;
83
		    indx = i;
83
		    break;
84
		    break;
84
		}
85
		}
-
 
86
	    }
85
	    /* Try for partial match */
87
	    /* Try for partial match */
86
	    if (partial && indx < 0) {
88
	    if (partial && indx < 0) {
87
		len = strlen(translateChar(STRING_ELT(s, pos)));
89
		len = strlen(translateChar(STRING_ELT(s, pos)));
88
		for(i = 0; i < nx; i++) {
90
		for(i = 0; i < nx; i++) {
89
		    if(!strncmp(translateChar(STRING_ELT(names, i)),
91
		    const char *tmp = translateChar(STRING_ELT(names, i));
-
 
92
		    if (!tmp[0]) continue;
90
				translateChar(STRING_ELT(s, pos)), len)) {
93
		    if(!strncmp(tmp, translateChar(STRING_ELT(s, pos)), len)) {
91
			if(indx == -1 )
94
			if(indx == -1 )
92
			    indx = i;
95
			    indx = i;
93
			else
96
			else
94
			    indx = -2;
97
			    indx = -2;
95
		    }
98
		    }
Line 167... Line 170...
167
	    indx = integerOneIndex((int)dblind, len, call);
170
	    indx = integerOneIndex((int)dblind, len, call);
168
	break;
171
	break;
169
    case STRSXP:
172
    case STRSXP:
170
	/* NA matches nothing */
173
	/* NA matches nothing */
171
	if(STRING_ELT(s, pos) == NA_STRING) break;
174
	if(STRING_ELT(s, pos) == NA_STRING) break;
-
 
175
	/* "" matches nothing: see names.Rd */
-
 
176
	if(!CHAR(STRING_ELT(s, pos))[0]) break;
172
	
177
	
173
	/* Try for exact match */
178
	/* Try for exact match */
174
	ss = translateChar(STRING_ELT(s, pos));
179
	ss = translateChar(STRING_ELT(s, pos));
175
	for (i = 0; i < length(names); i++) 
180
	for (i = 0; i < length(names); i++) 
176
	    if (STRING_ELT(names, i) != NA_STRING) {
181
	    if (STRING_ELT(names, i) != NA_STRING) {