|
From: Dave H. <da...@ho...> - 2015-08-02 23:56:24
|
Version 5.0 patchlevel 1 last modified 2015-06-07
I've just spotted a weird problem in one of my scripts. I'm manipulating
the date, and I have the line "month = `date +%m`" to extract the month as
a number.
Come August, and it appears as:
gnuplot> month = 08
^
"health.gp", line 51: unexpected or unrecognized token
My guess is that "08" is being parsed as an octal number, and hence
invalid; I could've sworn that this was working last year...
Anyone else seeing this?
--
Dave Horsfall DTM (VK2KFU) "Those who don't understand security will suffer."
Watson never said: "I think there is a world market for maybe five computers."
|
|
From: sfeam <sf...@us...> - 2015-08-03 00:10:05
|
On Monday, 03 August 2015 09:31:48 AM Dave Horsfall wrote:
> Version 5.0 patchlevel 1 last modified 2015-06-07
>
> I've just spotted a weird problem in one of my scripts. I'm manipulating
> the date, and I have the line "month = `date +%m`" to extract the month as
> a number.
>
> Come August, and it appears as:
>
> gnuplot> month = 08
> ^
> "health.gp", line 51: unexpected or unrecognized token
>
> My guess is that "08" is being parsed as an octal number, and hence
> invalid;
Correct
> I could've sworn that this was working last year...
Nope. This has been true since at least version 4.4 (March 2010)
although the error message has changed:
G N U P L O T
Version 4.4 patchlevel 0
last modified March 2010
System: Linux 3.14.43-desktop-1.mga4
Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help seeking-assistance"
immediate help: type "help"
plot window: hit 'h'
Terminal type set to 'wxt'
gnuplot> month = 08
^
';' expected
gnuplot> foo = 077
gnuplot> print foo
63
> Anyone else seeing this?
>
>
|
|
From: BBands <bb...@gm...> - 2015-08-03 00:43:55
|
It seems that the leading zero causes octal interpretation. I have no
problem with that, but as with floor division, another unexpected result by
most users, I think gp should at least warn. I know HBB will disagree, and
I understand his point, so perhaps the warnings could be switched off by an
'expert' compilation flag. Or the behaviors could be switched on and off
within the program??? Or a unique delimiter like '/' could be used. Feel
free to lynch, but I think that we ought to try for expected results, not
iso format dates for the first eight months of the year being converted to
octal. Python took floor division on, so perhaps we should too?
John
On Sun, Aug 2, 2015 at 4:31 PM, Dave Horsfall <da...@ho...> wrote:
> Version 5.0 patchlevel 1 last modified 2015-06-07
>
> I've just spotted a weird problem in one of my scripts. I'm manipulating
> the date, and I have the line "month = `date +%m`" to extract the month as
> a number.
>
> Come August, and it appears as:
>
> gnuplot> month = 08
> ^
> "health.gp", line 51: unexpected or unrecognized token
>
> My guess is that "08" is being parsed as an octal number, and hence
> invalid; I could've sworn that this was working last year...
>
> Anyone else seeing this?
>
|
|
From: sfeam <eam...@gm...> - 2015-08-03 01:39:26
|
On Sunday, 02 August 2015 05:43:48 PM BBands wrote: > It seems that the leading zero causes octal interpretation. I have no > problem with that, but as with floor division, another unexpected result by > most users, I think gp should at least warn. I know HBB will disagree, and > I understand his point, so perhaps the warnings could be switched off by an > 'expert' compilation flag. Or the behaviors could be switched on and off > within the program??? Or a unique delimiter like '/' could be used. Feel > free to lynch, but I think that we ought to try for expected results, not > iso format dates for the first eight months of the year being converted to > octal. There is no problem with iso format dates or indeed with any date/time formats. The time format routines strptime, strftime, etc do not interpret leading zeros as indicating an octal number. The issue only arises for integer assignment, not dates. > Python took floor division on, so perhaps we should too? > > John > > On Sun, Aug 2, 2015 at 4:31 PM, Dave Horsfall <da...@ho...> wrote: > > > Version 5.0 patchlevel 1 last modified 2015-06-07 > > > > I've just spotted a weird problem in one of my scripts. I'm manipulating > > the date, and I have the line "month = `date +%m`" to extract the month as > > a number. If it's in back-tics, it's being interpreted by the shell, not by gnuplot. So that particular example says nothing about how gnuplot processes month numbers. Ethan > > > > Come August, and it appears as: > > > > gnuplot> month = 08 > > ^ > > "health.gp", line 51: unexpected or unrecognized token > > > > My guess is that "08" is being parsed as an octal number, and hence > > invalid; I could've sworn that this was working last year... > > > > Anyone else seeing this? > > > ------------------------------------------------------------------------------ > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info |
|
From: Dave H. <da...@ho...> - 2015-08-03 18:22:07
|
On Sun, 2 Aug 2015, sfeam wrote: > > > I've just spotted a weird problem in one of my scripts. I'm > > > manipulating the date, and I have the line "month = `date +%m`" to > > > extract the month as a number. > > If it's in back-tics, it's being interpreted by the shell, not by > gnuplot. So that particular example says nothing about how gnuplot > processes month numbers. You sure it's the shell, and not the GP assignment "month = 08" ? I suppose I'll have to pipe it through "sed" or something; talk about violating the POLA... -- Dave Horsfall DTM (VK2KFU) "Those who don't understand security will suffer." Watson never said: "I think there is a world market for maybe five computers." |
|
From: Thomas S. <t.s...@fz...> - 2015-08-03 07:32:26
|
sfeam <eamerritt <at> gmail.com> writes: > ... > > On Sun, Aug 2, 2015 at 4:31 PM, Dave Horsfall <dave <at> horsfall.org> wrote: > > > > > Version 5.0 patchlevel 1 last modified 2015-06-07 > > > > > > I've just spotted a weird problem in one of my scripts. I'm manipulating > > > the date, and I have the line "month = `date +%m`" to extract the month as > > > a number. > > If it's in back-tics, it's being interpreted by the shell, > not by gnuplot. So that particular example says nothing about > how gnuplot processes month numbers. depending on the version of "date" you may switch padding off: #> date +%m 08 #> date +%-m 8 |
|
From: Dave H. <da...@ho...> - 2015-08-03 18:31:33
|
On Mon, 3 Aug 2015, Thomas Sefzick wrote: > depending on the version of "date" you may switch padding off: > > #> date +%m > 08 > #> date +%-m > 8 It works! It's an obscure glibc option; thanks. -- Dave Horsfall DTM (VK2KFU) "Those who don't understand security will suffer." Watson never said: "I think there is a world market for maybe five computers." |