The R Project SVN R

Rev

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

Rev 48415 Rev 49773
Line 159... Line 159...
159
		}
159
		}
160
		else {
160
		else {
161
		    /* recognise selected types from Table B-1 of K&R */
161
		    /* recognise selected types from Table B-1 of K&R */
162
		    /* NB: we deal with "%%" in branch above. */
162
		    /* NB: we deal with "%%" in branch above. */
163
		    /* This is MBCS-OK, as we are in a format spec */
163
		    /* This is MBCS-OK, as we are in a format spec */
164
		    chunk = strcspn(curFormat + 1, "disfeEgGxXaA") + 2;
164
		    chunk = strcspn(curFormat + 1, "diosfeEgGxXaA") + 2;
165
		    if (cur + chunk > n)
165
		    if (cur + chunk > n)
166
			error(_("unrecognised format specification '%s'"), curFormat);
166
			error(_("unrecognised format specification '%s'"), curFormat);
167
 
167
 
168
		    strncpy(fmt, curFormat, chunk);
168
		    strncpy(fmt, curFormat, chunk);
169
		    fmt[chunk] = '\0';
169
		    fmt[chunk] = '\0';
Line 267... Line 267...
267
			if(ns == 0) {
267
			if(ns == 0) {
268
			    SEXP tmp; Rboolean do_check;
268
			    SEXP tmp; Rboolean do_check;
269
			    switch(*findspec(fmtp)) {
269
			    switch(*findspec(fmtp)) {
270
			    case 'd':
270
			    case 'd':
271
			    case 'i':
271
			    case 'i':
-
 
272
			    case 'o':
272
			    case 'x':
273
			    case 'x':
273
			    case 'X':
274
			    case 'X':
274
				if(TYPEOF(_this) == REALSXP) {
275
				if(TYPEOF(_this) == REALSXP) {
275
				    double r = REAL(_this)[0];
276
				    double r = REAL(_this)[0];
276
				    if((double)((int) r) == r)
277
				    if((double)((int) r) == r)
Line 337... Line 338...
337
				break;
338
				break;
338
			    }
339
			    }
339
			case INTSXP:
340
			case INTSXP:
340
			    {
341
			    {
341
				int x = INTEGER(_this)[ns % thislen];
342
				int x = INTEGER(_this)[ns % thislen];
342
				if (checkfmt(fmtp, "dixX"))
343
				if (checkfmt(fmtp, "dioxX"))
343
				    error(_("invalid format '%s'; %s"), fmtp,
344
				    error(_("invalid format '%s'; %s"), fmtp,
344
					  _("use format %d, %i, %x or %X for integer objects"));
345
					  _("use format %d, %i, %o, %x or %X for integer objects"));
345
				if (x == NA_INTEGER) {
346
				if (x == NA_INTEGER) {
346
				    fmtp[strlen(fmtp)-1] = 's';
347
				    fmtp[strlen(fmtp)-1] = 's';
347
				    _my_sprintf("NA")
348
				    _my_sprintf("NA")
348
				} else {
349
				} else {
349
				    _my_sprintf(x)
350
				    _my_sprintf(x)