Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Problem with -v option (bug?)
Hi,
My system is Slackware 10 with gawk 3.1.3
When I run (in a bash) command
> cat times | awk  --source '{akt=$1*100+$2*(1.67)
> print akt}'

where times is
----times----
00 06
05 11
00 32
10 23
-----end-----

I get:
10,02
518,37
53,44
1038,41

which is what I expect to get (times is HOURS MINUTES \n, output is hom
much shoud user pay for using computer...)

Now, when I run
> cat times | awk  -v b=4 --source '{akt=$1*100+$2*(1.67)
> print akt}'
I get
6
511
32
1023

That is, gawk doesn't allo any floating point calculation. Why is that?
Is it possible it's a gawk-bug?

Best regards,
sirix.


Report this thread to moderator Post Follow-up to this message
Old Post
sirix
09-11-04 08:55 AM


Re: Problem with -v option (bug?)
In article <chkk44$rvr$1@news.onet.pl>, sirix  <sirix@poczta.onet.pl> wrote:
>Aharon Robbins wrote:
> 
>wrote: 
>I thought it's my stupid typo rather than bug.
> 
>Ok, it works now allright. Normally I use LC_ALL=pl_PL. I'm going to
>download and compile 3.1.4 - as soon as I've done it I write you an
>email with results.
>Just in case anybody bothers with that in future - I send this post also
>to c.l.awk newsgroup.
>
>I really appreciate your help, thanks very much.
>
>sirix.

I hate bottom posting, but since everyone here will yell at me if I
don't, what the heck.  I've posted a fix in bug-gnu-utils group, but
here it is in case anyone else wants it.

Thanks,

Arnold
----------------- cut here -------------------
Wed Sep  8 09:54:53 2004   Arnold D. Robbins    <arnold@skeeve.com>

* main.c (main): Force LC_NUMERIC locale to "C" before parsing
the program, since a variable assignment with -v can leave the
locale set incorrectly.

--- ../gawk-3.1.4/main.c	2004-07-28 16:42:19.000000000 +0300
+++ main.c      2004-09-08 09:53:46.000000000 +0300
@@ -532,6 +538,15 @@
init_args(optind, argc, (char *) myname, argv);
(void) tokexpand();

+#if defined(LC_NUMERIC)
+	/*
+	 * FRAGILE!  CAREFUL!
+	 * Pre-initing the variables with arg_assign() can change the
+	 * locale.  Force it to C before parsing the program.
+	 */
+	setlocale(LC_NUMERIC, "C");
+#endif
+
/* Read in the program */
if (yyparse() != 0 || errcount != 0)
exit(1);
--
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd.	arnold AT skeeve DOT com
P.O. Box 354		Home Phone: +972  8 979-0381	Fax: +1 206 350 8765
Nof Ayalon		Cell Phone: +972 50  729-7545
D.N. Shimshon 99785	ISRAEL

Report this thread to moderator Post Follow-up to this message
Old Post
Aharon Robbins
09-12-04 01:55 PM


Re: Problem with -v option (bug?)
Aharon Robbins wrote:

>In article <chkgqd$i5r$1@news.onet.pl>, sirix  <sirix@poczta.onet.pl>
wrote:
> 
>
>
>Greetings.  First, you should send bug reports to bug-gawk@gnu.org instead
>of posting them here; there's no guarantee otherwise that I'll see them.
>
I thought it's my stupid typo rather than bug.

>Looking more closely, it smells like a locale issue; try
>
>	export LC_ALL=C
>
Ok, it works now allright. Normally I use LC_ALL=pl_PL. I'm going to
download and compile 3.1.4 - as soon as I've done it I write you an
email with results.
Just in case anybody bothers with that in future - I send this post also
to c.l.awk newsgroup.

I really appreciate your help, thanks very much.

sirix.

Report this thread to moderator Post Follow-up to this message
Old Post
sirix
09-13-04 01:55 AM


Re: Problem with -v option (bug?)
In article <chkk44$rvr$1@news.onet.pl>, sirix  <sirix@poczta.onet.pl> wrote:
>Aharon Robbins wrote:
> 
>wrote: 
>I thought it's my stupid typo rather than bug.
> 
>Ok, it works now allright. Normally I use LC_ALL=pl_PL. I'm going to
>download and compile 3.1.4 - as soon as I've done it I write you an
>email with results.
>Just in case anybody bothers with that in future - I send this post also
>to c.l.awk newsgroup.
>
>I really appreciate your help, thanks very much.
>
>sirix.

I hate bottom posting, but since everyone here will yell at me if I
don't, what the heck.  I've posted a fix in bug-gnu-utils group, but
here it is in case anyone else wants it.

Thanks,

Arnold
----------------- cut here -------------------
Wed Sep  8 09:54:53 2004   Arnold D. Robbins    <arnold@skeeve.com>

* main.c (main): Force LC_NUMERIC locale to "C" before parsing
the program, since a variable assignment with -v can leave the
locale set incorrectly.

--- ../gawk-3.1.4/main.c	2004-07-28 16:42:19.000000000 +0300
+++ main.c      2004-09-08 09:53:46.000000000 +0300
@@ -532,6 +538,15 @@
init_args(optind, argc, (char *) myname, argv);
(void) tokexpand();

+#if defined(LC_NUMERIC)
+	/*
+	 * FRAGILE!  CAREFUL!
+	 * Pre-initing the variables with arg_assign() can change the
+	 * locale.  Force it to C before parsing the program.
+	 */
+	setlocale(LC_NUMERIC, "C");
+#endif
+
/* Read in the program */
if (yyparse() != 0 || errcount != 0)
exit(1);
--
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd.	arnold AT skeeve DOT com
P.O. Box 354		Home Phone: +972  8 979-0381	Fax: +1 206 350 8765
Nof Ayalon		Cell Phone: +972 50  729-7545
D.N. Shimshon 99785	ISRAEL

Report this thread to moderator Post Follow-up to this message
Old Post
Aharon Robbins
09-15-04 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:11 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.