The R Project SVN R

Rev

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

Rev 90254 Rev 90287
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
 *  Copyright (C) 1997--2025  The R Core Team
3
 *  Copyright (C) 1997--2026  The R Core Team
4
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
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 Pulic License as published by
7
 *  it under the terms of the GNU General Pulic 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
Line 1172... Line 1172...
1172
		return i;
1172
		return i;
1173
	    }
1173
	    }
1174
	return -1;
1174
	return -1;
1175
    }
1175
    }
1176
    if (!useBytes && use_UTF8) {
1176
    if (!useBytes && use_UTF8) {
-
 
1177
	// target is const char*, so C23 says so is the value
1177
	const char *pos = strstr(target, pat);
1178
	const char *pos = strstr(target, pat);
1178
	if (pos) {
1179
	if (pos) {
1179
	    int ib = (int) (pos-target);
1180
	    int ib = (int) (pos-target);
1180
	    int jb;
1181
	    int jb;
1181
 
1182
 
Line 1197... Line 1198...
1197
	    used = (int) Mbrtowc(NULL,  target+ib, R_MB_CUR_MAX, &mb_st);
1198
	    used = (int) Mbrtowc(NULL,  target+ib, R_MB_CUR_MAX, &mb_st);
1198
	    if (used <= 0) break;
1199
	    if (used <= 0) break;
1199
	    ib += used;
1200
	    ib += used;
1200
	}
1201
	}
1201
    } else {
1202
    } else {
-
 
1203
	// target is const char*, so C23 says so is the value
1202
	const char *pos = strstr(target, pat);
1204
	const char *pos = strstr(target, pat);
1203
	if (pos) {
1205
	if (pos) {
1204
	    i = (int) (pos-target);
1206
	    i = (int) (pos-target);
1205
	    if (next != NULL) *next = i + plen;
1207
	    if (next != NULL) *next = i + plen;
1206
	    return i;
1208
	    return i;
Line 1240... Line 1242...
1240
	    used = (int) Mbrtowc(NULL, target+ib, R_MB_CUR_MAX, &mb_st);
1242
	    used = (int) Mbrtowc(NULL, target+ib, R_MB_CUR_MAX, &mb_st);
1241
	    if (used <= 0) break;
1243
	    if (used <= 0) break;
1242
	    ib += used;
1244
	    ib += used;
1243
	}
1245
	}
1244
    } else {
1246
    } else {
-
 
1247
	// target is const char*, so C23 says so is the value
1245
	const char *pos = strstr(target, pat);
1248
	const char *pos = strstr(target, pat);
1246
	if (pos) return (int) (pos-target);
1249
	if (pos) return (int) (pos-target);
1247
    }
1250
    }
1248
    return -1;
1251
    return -1;
1249
}
1252
}