Re: [Rd] use of buffers in sprintf and snprintf

2019-05-31 Thread Gábor Csárdi
On Fri, May 31, 2019 at 3:39 AM Henrik Bengtsson
 wrote:
[...]
> On MS Windows, there's actually a limit of 255 characters, cf.
> http://www.aroma-project.org/howtos/UseLongFilenamesOnWindows/
> (disclaimer: I'm the author).  Note particularly the comment at the
> end:
>
> "Unfortunately it is not a solution to try to use relative instead of
> absolute pathnames. The limitation is deep down in the file system
> itself and it is the absolute pathname that counts."
>
> Admittedly, it's been several years when I last looked into it, but at
> the time when I wrote that I spent lots of time investigating it.

AFAICT NTFS supports path names up to 32,767 characters. The Unicode
Win API functions also support these, or you can just prefix the paths
with \\?\ to support them. I don't know if there is anything in R that
would prevent using the \\?\ prefix but just doing a file() on them
seems to work fine.

Gabor


> /Henrik
>
> >
> > Cheers,
> > Simon
> >
> >
> >
> >
> > > On May 29, 2019, at 11:49 AM, jing hua zhao  
> > > wrote:
> > >
> > > Dear R-developers,
> > >
> > > I am struggling with packaging with sprintf and snprintf() as the 
> > > following WARNINGS from gcc 9.x,
> > >
> > >  hap_c.c:380:46: warning: �%d� directive output may be truncated writing 
> > > between 1 and 10 bytes into a region of size between 0 and 127 
> > > [-Wformat-truncation=]
> > >  hap_c.c:392:46: warning: �%d� directive output may be truncated writing 
> > > between 1 and 10 bytes into a region of size between 0 and 127 
> > > [-Wformat-truncation=]
> > >
> > > Essentially, I have
> > >
> > > #define MAX_FILENAME_LEN 128
> > > char of1name[MAX_FILENAME_LEN],of2name[MAX_FILENAME_LEN], 
> > > tempname[MAX_FILENAME_LEN];
> > >
> > > ...
> > >
> > > snprintf(tempname,sizeof(tempname),"%s.%d", of1name, j);
> > >
> > > It looks I could get around with
> > >
> > >
> > > #define MAX_FILENAME_LEN 128
> > >
> > > #define MAX_FILENAME_LEN2 256
> > >
> > > char of1name[MAX_FILENAME_LEN],of2name[MAX_FILENAME_LEN], 
> > > tempname[MAX_FILENAME_LEN2];
> > >
> > > ...
> > > snprintf(tempname,2*sizeof(tempname)+1,"%s.%d", of1name, j)
> > >
> > > It looks a bit waste of resources to me.
> > >
> > >
> > > Any idea will be greatly appreciated,
> > >
> > >
> > >
> > > Jing Hua
> > >
> > >   [[alternative HTML version deleted]]
> > >
> > > __
> > > R-devel@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

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


Re: [Rd] R pkg install should fail for unsuccessful DLL copy on windows?

2019-05-31 Thread Toby Hocking
thanks for your input Hervé. Glad to hear I'm not the only one still having
this issue.

In my opinion install.packages should stop with an error (instead of a
warning) if this happens.

However even if you want to keep the warning, at least make it so that
users can set options(warn=2) to get an error if they want one. I tried
setting options(warn=2) but for some reason I still get a warning.

I believe that is a bug in install.packages -- if I specify options(warn=2)
it should convert that warning to an error (but it currently does not).

Toby

On Thu, May 30, 2019 at 4:50 PM Pages, Herve  wrote:

> Also note that this can lead to people not being able to load the
> package if the set of .Call entry points has changed between the old
> and new versions of the package. We strongly suspect that this is what
> happened to this Bioconductor user:
>
>https://support.bioconductor.org/p/121228/
>
> Note that she's installing the binary and in this case no warning
> is issued. All we see is:
>
>package ‘S4Vectors’ successfully unpacked and MD5 sums checked
>
> but the old DLL apparently didn't get replaced with the new one.
> Hence the
>
>error: "make_RAW_from_NA_LLINT" not available for .Call() for package
> "S4Vectors"
>
> later on when trying to load the package.
>
> Cheers,
> H.
>
>
> On 5/30/19 16:31, Toby Hocking wrote:
> > thanks for the tip Jan.
> >
> > However it would be nice if I didn't have to handle this myself for all
> of
> > my packages. (and teach my students how to do that)
> >
> > BTW I tried to disable staged installation, and the issue still happens:
> >
> > th798@cmp2986 MINGW64 ~/projects/max-generalized-auc (master)
> > $ R_INSTALL_STAGED=FALSE R --vanilla -e
> > ".libPaths('~/R/library');.libPaths();options(repos='
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__cloud.r-2Dproject.org&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=zldJhdavBFtHDHr08_HFRAi9MY2WBkTiDn1ggbog4cA&s=7X00xNRObhT9O68YU8m-IBkt38N5p_GP-UV77XEnKZw&e=
> ',
> > warn=2);library(penaltyLearning);install.packages('penaltyLearning',
> > type='source');getOption('warn');sessionInfo()"
> >
> > R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
> > Copyright (C) 2019 The R Foundation for Statistical Computing
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> >
> > R is free software and comes with ABSOLUTELY NO WARRANTY.
> > You are welcome to redistribute it under certain conditions.
> > Type 'license()' or 'licence()' for distribution details.
> >
> > R is a collaborative project with many contributors.
> > Type 'contributors()' for more information and
> > 'citation()' on how to cite R or R packages in publications.
> >
> > Type 'demo()' for some demos, 'help()' for on-line help, or
> > 'help.start()' for an HTML browser interface to help.
> > Type 'q()' to quit R.
> >
> >> .libPaths('~/R/library');.libPaths();options(repos='
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__cloud.r-2Dproject.org&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=zldJhdavBFtHDHr08_HFRAi9MY2WBkTiDn1ggbog4cA&s=7X00xNRObhT9O68YU8m-IBkt38N5p_GP-UV77XEnKZw&e=
> ',
> > warn=2);library(penaltyLearning);install.packages('penaltyLearning',
> > type='source');getOption('warn');sessionInfo()
> > [1] "C:/Users/th798/R/library"   "C:/Program
> > Files/R/R-3.6.0/library"
> > Loading required package: data.table
> > Registered S3 methods overwritten by 'ggplot2':
> >method from
> >[.quosures rlang
> >c.quosures rlang
> >print.quosures rlang
> > Installing package into 'C:/Users/th798/R/library'
> > (as 'lib' is unspecified)
> > trying URL '
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__cloud.r-2Dproject.org_src_contrib_penaltyLearning-5F2018.09.04.tar.gz&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=zldJhdavBFtHDHr08_HFRAi9MY2WBkTiDn1ggbog4cA&s=o34c6BnD4LvJv-00tYn5M2TqO_IjH5qtaKnnhI4ph50&e=
> '
> > Content type 'application/x-gzip' length 2837289 bytes (2.7 MB)
> > ==
> > downloaded 2.7 MB
> >
> > * installing *source* package 'penaltyLearning' ...
> > ** package 'penaltyLearning' successfully unpacked and MD5 sums checked
> > ** using non-staged installation
> > ** libs
> > c:/Rtools/mingw_64/bin/g++  -std=gnu++11
> -I"C:/PROGRA~1/R/R-36~1.0/include"
> > -DNDEBUG  -O2 -Wall  -mtune=generic -c interface.cpp -o
> interface.o
> > c:/Rtools/mingw_64/bin/g++  -std=gnu++11
> -I"C:/PROGRA~1/R/R-36~1.0/include"
> > -DNDEBUG  -O2 -Wall  -mtune=generic -c
> largestContinuousMinimum.cpp
> > -o largestContinuousMinimum.o
> > largestContinuousMinimum.cpp: In function 'int
> > largestContinuousMinimum(int, double*, double*, int*)':
> > largestContinuousMinimum.cpp:38:27: warning: 'start' may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> > index_vec[0] = start;
> >