Package: worklog
Version: 1.8-4
Severity: wishlist
Tags: patch

use amounts within the brackets, since they are more accurate

Once this patch is applied, the initial text could be removed, but maybe it 
should be 
left to remain backward compatible.

This rounding errors also shows up as accurate results entered into the 
time.log the 
first time, but if you restart/stop worklog, the time in time.log will go 
*down* even 
if that project wasn't worked on during that session.

The initial sscanf doesn't do what the author thought it did, I think, or at 
least, 
there is extra information that makes it look like it is parsing the "hours :" 
bit very 
carefully, but sscanf ignores everything past the first %lf match.

Modified: vendor/worklog/mine/worklog.c
===================================================================
--- vendor/worklog/mine/worklog.c       2009-09-25 18:12:06 UTC (rev 9554)
+++ vendor/worklog/mine/worklog.c       2009-09-25 18:14:49 UTC (rev 9555)
@@ -61,6 +61,7 @@
     char specific_timefile[STRLEN] ;
     char line[STRLEN] ;
     FILE *fa ;
+    char timetype[STRLEN];

     result=0.0 ;
     sprintf(specific_timefile,"%s.%c",log_filename,project->key) ;
@@ -78,8 +79,26 @@
     else
     {
         for(;1==fscanf(fa,"%[^\n]",line);fscanf(fa,"\n"))
-            if(1==sscanf(line,"%lf hours :",&partial))
-                result+=(long) rint(partial*60.0*60.0) ;
+        {
+                // [Jon Daley: 2009-09-25] make file parsing more accurate
+                // by using the amounts within the brackets, rather than
+                // the (rounded) amounts at the beginning of the line
+            if(2==sscanf(line,"%*[^[][%lf %s :",&partial, &timetype))
+            {
+                if(strcmp(timetype, "hours]") == 0)
+                    result+=(long) rint(partial*60.0*60.0) ;
+                else if(strcmp(timetype, "minutes]") == 0)
+                    result+=(long) rint(partial*60.0) ;
+                else if(strcmp(timetype, "seconds]") == 0)
+                    result+=(long) rint(partial) ;
+                else
+                    printf("Couldn't find timetype: %s, %s\n", line, timetype);
+            }
+            else
+            {
+                printf("Couldn't find timestamp: %s\n", line);
+            }
+        }
     }
     fclose(fa) ;



-- System Information:
Debian Release: 5.0.3
  APT prefers proposed-updates
  APT policy: (500, 'proposed-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ANSI_X3.4-1968) (ignored: LC_ALL 
set to C)
Shell: /bin/sh linked to /bin/bash

Versions of packages worklog depends on:
ii  libc6                     2.7-18         GNU C Library: Shared libraries
ii  libncurses5               5.7+20081213-1 shared libraries for terminal hand

worklog recommends no packages.

worklog suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to