View | Details | Raw Unified | Return to bug 17398 | Differences between
and this patch

Collapse All | Expand All

(-)src/library/base/R/print.R (-2 / +2 lines)
Lines 45-52 print.default <- function(x, digits = NULL, quote = TRUE, na.print = NULL, Link Here
45
45
46
    noOpt <- all(missings) && missing(...)
46
    noOpt <- all(missings) && missing(...)
47
47
48
    .Internal(print.default(x, digits, quote, na.print, print.gap, right, max,
48
    .Internal(print.default(x, parent.frame(), digits, quote, na.print, print.gap,
49
                            useSource, noOpt, userArgs))
49
                            right, max, useSource, noOpt, userArgs))
50
}
50
}
51
51
52
prmatrix <-
52
prmatrix <-
(-)src/main/names.c (-1 / +1 lines)
Lines 681-687 FUNTAB R_FunTab[] = Link Here
681
{"dump",	do_dump,	0,	111,	5,	{PP_FUNCALL, PREC_FN,	0}},
681
{"dump",	do_dump,	0,	111,	5,	{PP_FUNCALL, PREC_FN,	0}},
682
{"quit",	do_quit,	0,	111,	3,	{PP_FUNCALL, PREC_FN,	0}},
682
{"quit",	do_quit,	0,	111,	3,	{PP_FUNCALL, PREC_FN,	0}},
683
{"readline",	do_readln,	0,	11,	1,	{PP_FUNCALL, PREC_FN,	0}},
683
{"readline",	do_readln,	0,	11,	1,	{PP_FUNCALL, PREC_FN,	0}},
684
{"print.default",do_printdefault,0,	111,   10,	{PP_FUNCALL, PREC_FN,	0}},
684
{"print.default",do_printdefault,0,	111,   11,	{PP_FUNCALL, PREC_FN,	0}},
685
{"prmatrix",	do_prmatrix,	0,	111,	6,	{PP_FUNCALL, PREC_FN,	0}},
685
{"prmatrix",	do_prmatrix,	0,	111,	6,	{PP_FUNCALL, PREC_FN,	0}},
686
{"gc",		do_gc,		0,	11,	3,	{PP_FUNCALL, PREC_FN,	0}},
686
{"gc",		do_gc,		0,	11,	3,	{PP_FUNCALL, PREC_FN,	0}},
687
{"gcinfo",	do_gcinfo,	0,	11,	1,	{PP_FUNCALL, PREC_FN,	0}},
687
{"gcinfo",	do_gcinfo,	0,	11,	1,	{PP_FUNCALL, PREC_FN,	0}},
(-)src/main/print.c (-4 / +5 lines)
Lines 192-203 static void PrintClosure(SEXP s, Rboolean useSource) Link Here
192
			   right, max, useS4)) */
192
			   right, max, useS4)) */
193
SEXP attribute_hidden do_printdefault(SEXP call, SEXP op, SEXP args, SEXP rho)
193
SEXP attribute_hidden do_printdefault(SEXP call, SEXP op, SEXP args, SEXP rho)
194
{
194
{
195
    SEXP x, naprint;
195
    SEXP naprint;
196
196
197
    checkArity(op, args);
197
    checkArity(op, args);
198
    PrintDefaults();
198
    PrintDefaults();
199
199
200
    x = CAR(args); args = CDR(args);
200
    SEXP x = CAR(args); args = CDR(args);
201
    SEXP env = CAR(args); args = CDR(args);
201
202
202
    if(!isNull(CAR(args))) {
203
    if(!isNull(CAR(args))) {
203
	R_print.digits = asInteger(CAR(args));
204
	R_print.digits = asInteger(CAR(args));
Lines 257-265 SEXP attribute_hidden do_printdefault(SEXP call, SEXP op, SEXP args, SEXP rho) Link Here
257
258
258
    tagbuf[0] = '\0';
259
    tagbuf[0] = '\0';
259
    if (noParams && IS_S4_OBJECT(x) && isMethodsDispatchOn())
260
    if (noParams && IS_S4_OBJECT(x) && isMethodsDispatchOn())
260
        PrintObject(x, rho);
261
        PrintObject(x, env);
261
    else
262
    else
262
        PrintValueRec(x, rho);
263
        PrintValueRec(x, env);
263
264
264
    PrintDefaults(); /* reset, as na.print etc may have been set */
265
    PrintDefaults(); /* reset, as na.print etc may have been set */
265
    return x;
266
    return x;
(-)tests/print-tests.R (+13 lines)
Lines 343-345 print(d, digits = 4L, other = TRUE) Link Here
343
print(list(a, expression(foo), b, quote(foo), c, base::list, d), digits = 4L, other = TRUE)
343
print(list(a, expression(foo), b, quote(foo), c, base::list, d), digits = 4L, other = TRUE)
344
344
345
rm(print.foo, obj, a, b, c, d)
345
rm(print.foo, obj, a, b, c, d)
346
347
348
## Locally-defined methods work when print.default() is called
349
print.foo <- function(...) stop("should not be called")
350
local({
351
    print.foo <- function(...) cat("OK\n")
352
    obj <- structure(list(), class = "foo")
353
    print(obj)
354
    print(pairlist(obj))
355
    print(structure(list(), attr = obj))
356
    print(list(list(obj, pairlist(obj, structure(list(obj), attr = obj)))))
357
})
358
rm(print.foo)
(-)tests/print-tests.Rout.save (-1 / +37 lines)
Lines 948-950 NULL Link Here
948
> 
948
> 
949
> rm(print.foo, obj, a, b, c, d)
949
> rm(print.foo, obj, a, b, c, d)
950
> 
950
> 
951
- 
951
> 
952
> ## Locally-defined methods work when print.default() is called
953
> print.foo <- function(...) stop("should not be called")
954
> local({
955
+     print.foo <- function(...) cat("OK\n")
956
+     obj <- structure(list(), class = "foo")
957
+     print(obj)
958
+     print(pairlist(obj))
959
+     print(structure(list(), attr = obj))
960
+     print(list(list(obj, pairlist(obj, structure(list(obj), attr = obj)))))
961
+ })
962
OK
963
[[1]]
964
OK
965
966
list()
967
attr(,"attr")
968
OK
969
[[1]]
970
[[1]][[1]]
971
OK
972
973
[[1]][[2]]
974
[[1]][[2]][[1]]
975
OK
976
977
[[1]][[2]][[2]]
978
[[1]][[2]][[2]][[1]]
979
OK
980
981
attr(,"attr")
982
OK
983
984
985
986
> rm(print.foo)
987
> 

Return to bug 17398