[Rd] [PATCH] Ensure correct order of evaluation in macro

2017-05-22 Thread Sahil Kang

Hello,

I'd like to contribute this small patch (attached) that I think will 
help prevent some future bugs from occurring in paste.c.
By wrapping the macro's arguments in parentheses, we can ensure that the 
correct order of evaluation will take place during preprocessing.


To illustrate, we can use the == operator which has lower evaluation 
precedence than the < operator:

* With the current macro, imax2(3==4, 1) expands to 0.
* After applying this patch, imax2(3==4, 1) expands to 1 as expected.

Since I'm still relatively new to the mailing list, I've kept this patch 
small.
I did notice other macros that have this same issue, so I can start 
sending additional patches if this seems okay.


Thanks,
Sahil
Index: src/main/paste.c
===
--- src/main/paste.c	(revision 72713)
+++ src/main/paste.c	(working copy)
@@ -31,7 +31,7 @@
 #include "Defn.h"
 #include 
 
-#define imax2(x, y) ((x < y) ? y : x)
+#define imax2(x, y) (((x) < (y)) ? (y) : (x))
 
 #include "Print.h"
 #include "RBufferUtils.h"
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] [R] Somewhat obscure bug in R 3.4.0 building from source

2017-05-22 Thread Peter Carbonetto
Hi Peter, Duncan & Bert,

Thank you kindly for the responses.

Indeed, doc/NEWS.pdf is included in the source distribution, and then
removed upon "make clean".

I thought that it might be useful to report this for your benefit, but on
closer inspection it appears that I'm getting errors that arise due to
incompatibilities in my texlive and texinfo installations. This is the
error I get when trying to build NEWS.pdf using "R CMD Rd2pdf":

R CMD Rd2pdf --output=NEWS.pdf NEWS.Rd
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet,  :
  Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
/software/texinfo-6.3-el7-x86_64/bin/texi2dvi: TeX neither supports
-recorder nor outputs \openout lines in its log file
Output:

I'm not sure what to make of this error exactly but perhaps it is
introduced by the latest version of texinfo (which seems to be a recurring
issue based on reading the help for texi2dvi in R):

texi2dvi --version
texi2dvi (GNU Texinfo 6.3) 7353

Peter

On Sun, May 21, 2017 at 5:07 PM, Peter Dalgaard  wrote:

> Inline below...
>
> > On 21 May 2017, at 20:57 , Duncan Murdoch 
> wrote:
> >
> > On 21/05/2017 10:30 AM, Peter Carbonetto wrote:
> >> Hi,
> >>
> >> I uncovered a bug in installing R 3.4.0 from source in Linux, following
> the
> >> standard procedure (configure; make; make install). Is this an
> appropriate
> >> place to report this bug? If not, can you please direct me to the
> >> appropriate place?
> >
> > Generally R-devel is better; I've responded there.
> >
> >>
> >> The error occurs only when I do "make clean" followed by "make" again;
> make
> >> works the first time.
> >>
> >> The error is a failure to build NEWS.pdf:
> >>
> >> Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
> quiet,  :
> >>  pdflatex is not available
> >> Calls:  -> texi2pdf -> texi2dvi
> >> Execution halted
> >> make[1]: *** [NEWS.pdf] Error 1
> >> make: [docs] Error 2 (ignored)
> >>
> >> and can be reproduced wit the following sequence:
> >>
> >> ./configure
> >> make
> >> make clean
> >> make
> >
> > We usually don't build in the source directory; see the second
> recommendation in the admin manual section 2.1.  So it's possible there's a
> bug triggered when you do that.  Can you try building in a separate
> directory?
>
> Notice that the error is that "pdflatex" is missing from your setup. We
> do, for the benefit of users with defective TeX installations supply a
> pre-built NEWS.pdf (and NEWS.html too) in the source tarballs. However,
> they are technically make targets and make clean will wipe them; in that
> case, you had better have the tools to rebuild them!
>
> -pd
>
> >
> > Duncan Murdoch
> >
> >>
> >> This suggests to me that perhaps "make clean" is not working.
> >>
> >> I'm happy to provide more details so that you are able to reproduce the
> bug.
> >>
> >> Thanks,
> >>
> >> Peter Carbonetto, Ph.D.
> >> Computational Staff Scientist, Statistics & Genetics
> >> Research Computing Center
> >> University of Chicago
> >>
> >>  [[alternative HTML version deleted]]
> >>
> >> __
> >> r-h...@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R] Somewhat obscure bug in R 3.4.0 building from source

2017-05-22 Thread Prof Brian Ripley

On 22/05/2017 18:16, Peter Carbonetto wrote:

Hi Peter, Duncan & Bert,

Thank you kindly for the responses.

Indeed, doc/NEWS.pdf is included in the source distribution, and then
removed upon "make clean".

I thought that it might be useful to report this for your benefit, but on
closer inspection it appears that I'm getting errors that arise due to
incompatibilities in my texlive and texinfo installations. This is the
error I get when trying to build NEWS.pdf using "R CMD Rd2pdf":

R CMD Rd2pdf --output=NEWS.pdf NEWS.Rd
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet,  :
   Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
/software/texinfo-6.3-el7-x86_64/bin/texi2dvi: TeX neither supports
-recorder nor outputs \openout lines in its log file
Output:

I'm not sure what to make of this error exactly but perhaps it is
introduced by the latest version of texinfo (which seems to be a recurring
issue based on reading the help for texi2dvi in R):

texi2dvi --version
texi2dvi (GNU Texinfo 6.3) 7353


Please do not speculate (see the posting guide and FAQ).

That version is thoroughly tested.  texinfo troubles were mainly in the 
transition to Perl ca 5.[012], and its slow adoption by distros: another 
holdback has been the transition to GPL-3-only licensing, AFAIR at 6.0.





Peter

On Sun, May 21, 2017 at 5:07 PM, Peter Dalgaard  wrote:


Inline below...


On 21 May 2017, at 20:57 , Duncan Murdoch 

wrote:


On 21/05/2017 10:30 AM, Peter Carbonetto wrote:

Hi,

I uncovered a bug in installing R 3.4.0 from source in Linux, following

the

standard procedure (configure; make; make install). Is this an

appropriate

place to report this bug? If not, can you please direct me to the
appropriate place?


Generally R-devel is better; I've responded there.



The error occurs only when I do "make clean" followed by "make" again;

make

works the first time.

The error is a failure to build NEWS.pdf:

Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =

quiet,  :

  pdflatex is not available
Calls:  -> texi2pdf -> texi2dvi
Execution halted
make[1]: *** [NEWS.pdf] Error 1
make: [docs] Error 2 (ignored)

and can be reproduced wit the following sequence:

./configure
make
make clean
make


We usually don't build in the source directory; see the second

recommendation in the admin manual section 2.1.  So it's possible there's a
bug triggered when you do that.  Can you try building in a separate
directory?

Notice that the error is that "pdflatex" is missing from your setup. We
do, for the benefit of users with defective TeX installations supply a
pre-built NEWS.pdf (and NEWS.html too) in the source tarballs. However,
they are technically make targets and make clean will wipe them; in that
case, you had better have the tools to rebuild them!

-pd



Duncan Murdoch



This suggests to me that perhaps "make clean" is not working.

I'm happy to provide more details so that you are able to reproduce the

bug.


Thanks,

Peter Carbonetto, Ph.D.
Computational Staff Scientist, Statistics & Genetics
Research Computing Center
University of Chicago

  [[alternative HTML version deleted]]

__
r-h...@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/

posting-guide.html

and provide commented, minimal, self-contained, reproducible code.



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com












[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel