Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-06-01 Thread Martin Maechler
PS == Petr Savicky savi...@cs.cas.cz on Sun, 31 May 2009 10:29:41 +0200 writes: [] PS I appreciate the current version, which contains static PS const char* dropTrailing0(char *s, char cdec) ... PS mkChar(dropTrailing0((char *)EncodeReal(x, w, d, e, PS OutDec),

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-06-01 Thread Wacek Kusnierczyk
Martin Maechler wrote: PS == Petr Savicky savi...@cs.cas.cz on Sun, 31 May 2009 10:29:41 +0200 writes: [] PS I appreciate the current version, which contains static PS const char* dropTrailing0(char *s, char cdec) ... PS mkChar(dropTrailing0((char

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-31 Thread Petr Savicky
On Sat, May 30, 2009 at 07:32:52PM +0200, Martin Maechler wrote: vQ == Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no on Sat, 30 May 2009 11:16:43 +0200 writes: [...] vQ one simple way to improve the code is as follows; instead of (simplified) vQ const char*

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Wacek Kusnierczyk
Martin Maechler wrote: Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch against that. some further investigation and reflections on the code in StringFromReal (henceforth SFR), src/main/coerce.c:315 (as in the

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Uwe Ligges
Wacek Kusnierczyk wrote: Martin Maechler wrote: Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch against that. some further investigation and reflections on the code in StringFromReal (henceforth SFR),

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Martin Maechler
2009/5/30 Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no: Martin Maechler wrote: Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch against that. Hi Martin, One quick reaction (which does not resolve

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Martin Maechler
vQ == Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no on Sat, 30 May 2009 11:16:43 +0200 writes: vQ Martin Maechler wrote: Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-30 Thread Wacek Kusnierczyk
Martin Maechler wrote: [...] vQ the first question is, why does ER return the string as const? it vQ appears that the returned pointer provides the address of a buffer used vQ internally in ER, which is allocated *statically*. that is, each call vQ to ER operates on the

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Martin Maechler
PS == Petr Savicky savi...@cs.cas.cz on Thu, 28 May 2009 09:36:48 +0200 writes: PS On Wed, May 27, 2009 at 10:51:38PM +0200, Martin Maechler wrote: I have very slightly modified the changes (to get rid of -Wall warnings) and also exported the function as Rf_dropTrailing0(),

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Martin Maechler
vQ == Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no on Thu, 28 May 2009 00:36:07 +0200 writes: vQ Martin Maechler wrote: I have very slightly modified the changes (to get rid of -Wall warnings) and also exported the function as Rf_dropTrailing0(), and

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Petr Savicky
On Fri, May 29, 2009 at 03:53:02PM +0200, Martin Maechler wrote: my version of *using* the function was 1 SEXP attribute_hidden StringFromReal(double x, int *warn) 2 { 3 int w, d, e; 4 formatReal(x, 1, w, d, e, 0); 5 if (ISNA(x)) return NA_STRING; 6 else return

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Wacek Kusnierczyk
Petr Savicky wrote: On Fri, May 29, 2009 at 03:53:02PM +0200, Martin Maechler wrote: my version of *using* the function was 1 SEXP attribute_hidden StringFromReal(double x, int *warn) 2 { 3 int w, d, e; 4 formatReal(x, 1, w, d, e, 0); 5 if (ISNA(x)) return NA_STRING; 6 else

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Wacek Kusnierczyk
Martin Maechler wrote: [...] vQ you return s, which should be the same pointer value (given the actual vQ code that does not modify the local variable s) with the same pointed-to vQ string value (given the signature of the function). vQ was perhaps vQ char

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Martin Maechler
Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch against that. Thank you in advance! Martin On Fri, May 29, 2009 at 21:54, Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote: Martin Maechler wrote:

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Wacek Kusnierczyk
Martin Maechler wrote: Hi Waclav (and other interested parties), I have committed my working version of src/main/coerce.c so you can prepare your patch against that. Hi Martin, One quick reaction (which does not resolve my original complaint): you can have p non-const, and cast s to

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-28 Thread Petr Savicky
On Wed, May 27, 2009 at 10:51:38PM +0200, Martin Maechler wrote: I have very slightly modified the changes (to get rid of -Wall warnings) and also exported the function as Rf_dropTrailing0(), and tested the result with 'make check-all' . Thank you very much for considering the patch. -Wall

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-27 Thread Martin Maechler
PS == Petr Savicky savi...@cs.cas.cz on Sat, 23 May 2009 09:44:54 +0200 writes: PS Function factor() in the current development version PS (2009-05-22) guarantees that levels are different PS character strings. However, they may represent the same PS decimal number. The

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-27 Thread Wacek Kusnierczyk
Martin Maechler wrote: I have very slightly modified the changes (to get rid of -Wall warnings) and also exported the function as Rf_dropTrailing0(), and tested the result with 'make check-all' . As the change seems reasonable and consequent, and as it seems not to produce any problems in