The R Project SVN R

Rev

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

Rev 50880 Rev 51398
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) 1995, 1996  Robert Gentleman and Ross Ihaka
3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4
 *  Copyright (C) 1997--2007  The R Development Core Team
4
 *  Copyright (C) 1997--2010  The R Development 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 443... Line 443...
443
 
443
 
444
	case STRSXP:
444
	case STRSXP:
445
	{
445
	{
446
	    /* this has to be different from formatString/EncodeString as
446
	    /* this has to be different from formatString/EncodeString as
447
	       we don't actually want to encode here */
447
	       we don't actually want to encode here */
448
	    const char *s; char *buff, *q;
448
	    const char *s; 
-
 
449
	    char *q;
449
	    int b, b0, cnt = 0, j;
450
	    int b, b0, cnt = 0, j;
450
	    SEXP s0, xx;
451
	    SEXP s0, xx;
451
 
452
 
452
	    /* This is clumsy, but it saves rewriting and re-testing
453
	    /* This is clumsy, but it saves rewriting and re-testing
453
	       this complex code */
454
	       this complex code */
Line 469... Line 470...
469
	    for (i = 0; i < n; i++)
470
	    for (i = 0; i < n; i++)
470
		if (STRING_ELT(xx, i) != NA_STRING) {
471
		if (STRING_ELT(xx, i) != NA_STRING) {
471
		    il = Rstrlen(STRING_ELT(xx, i), 0);
472
		    il = Rstrlen(STRING_ELT(xx, i), 0);
472
		    cnt = imax2(cnt, LENGTH(STRING_ELT(xx, i)) + imax2(0, w-il));
473
		    cnt = imax2(cnt, LENGTH(STRING_ELT(xx, i)) + imax2(0, w-il));
473
		} else if (na) cnt  = imax2(cnt, R_print.na_width + imax2(0, w-R_print.na_width));
474
		} else if (na) cnt  = imax2(cnt, R_print.na_width + imax2(0, w-R_print.na_width));
474
	    buff = (char *) alloca(cnt+1);
475
	    char buff[cnt+1];
475
	    R_CheckStack();
476
	    R_CheckStack();
476
	    PROTECT(y = allocVector(STRSXP, n));
477
	    PROTECT(y = allocVector(STRSXP, n));
477
	    for (i = 0; i < n; i++) {
478
	    for (i = 0; i < n; i++) {
478
		if(!na && STRING_ELT(xx, i) == NA_STRING) {
479
		if(!na && STRING_ELT(xx, i) == NA_STRING) {
479
		    SET_STRING_ELT(y, i, NA_STRING);
480
		    SET_STRING_ELT(y, i, NA_STRING);