From c@@rd|@g@bor @end|ng |rom gm@||@com  Fri May 31 09:51:49 2019
From: c@@rd|@g@bor @end|ng |rom gm@||@com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Fri, 31 May 2019 08:51:49 +0100
Subject: [Rd] use of buffers in sprintf and snprintf
In-Reply-To: <CAFDcVCRCnvwjvDYSq6tRTBJGg-4A+isjE+mJ3HiAA3guqBmQDA@mail.gmail.com>
References: <32da856c-a60a-974f-65ab-d7123e12e813@daqana.com>
 <23307.48529.773039.904392@stat.math.ethz.ch>
 <23307.49323.908367.788461@stat.math.ethz.ch>
 <CABtg=KkuVHoX1tZ=+Lr7mDFrXvn5zdf3+Wmqhnv58GXZJS2KwQ@mail.gmail.com>
 <f3388993-5e20-d7e5-346a-785d33fab27b@daqana.com>
 <DB6P189MB0581F101B909FA1E2ACC509DA51F0@DB6P189MB0581.EURP189.PROD.OUTLOOK.COM>
 <A863224C-6DBD-45DA-A9A8-45A2D25613DA@R-project.org>
 <CAFDcVCRCnvwjvDYSq6tRTBJGg-4A+isjE+mJ3HiAA3guqBmQDA@mail.gmail.com>
Message-ID: <CABtg=KkwObHZCetM2hAL1-dpNT1Uk3mtEOMQ7n=vxjSdqkhQjA@mail.gmail.com>

On Fri, May 31, 2019 at 3:39 AM Henrik Bengtsson
<henrik.bengtsson at gmail.com> 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 <jinghuazhao at hotmail.com> 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 at r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] use of buffers in sprintf and snprintf
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=