Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#111 Fix errors about converting '-' to int

open
nobody
None
5
2014-08-28
2006-05-29
Patrick Horn
No

I just upgraded to AWStats 6.6 (Gentoo), and I noticed
a string of errors like:
Argument "-" isn't numeric in int at
/home/www/localhost/cgi-bin/awstats.perl
line 6710, <LOG> line 307 (#1)
in my cron output.

These errors happened at many other places (everywhere
it called int()).

At 6710, I noticed that it was casting
$field[$pos_size] to an int.
It also had this comment:

TODO can cause a warning

I fixed the warnings by adding an "if
($field[$pos_size] ne '-')" around all of the error areas.

I figure it should not change anything since (in C at
least) 0 is the default for bad strings, so it should
add nothing in the case that there is a '-'.

I understand that my way may not have been the best way
to patch it. I am a C person and have never touched
perl in my life, so there may have been a much more
obvious way to fix this. Maybe you could make a
function to replace int() that checks for '-' and then
casts to int, and call it instead wherever you say int().

Anyway, I hope some fix is put in place to fix these
warnings for 6.6 final. I don't like getting 1000-line
cron e-mails full of these messages. :-p

Discussion

  • Patrick Horn
    Patrick Horn
    2006-05-29

    Patch to check for strings equal to '-' before casting them to int

     
    Attachments
  • Patrick Horn
    Patrick Horn
    2006-05-29

    Logged In: YES
    user_id=284053

    To be more specific, it is likely referring to these types
    of lines in my log file:
    68.142.251.204 - - [05/Mar/2006:02:32:57 -0800] "GET
    /robots.txt HTTP/1.0" 200 - "-" "Mozilla/5.0 (compatible;
    Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"

    81.169.154.94 - - [05/Mar/2006:02:37:27 -0800] "HEAD /
    HTTP/1.1" 200 - "-" "Mozilla/4.0 (compatible; MSIE 6.0;
    Windows NT 5.0; ODP links test;
    http://tuezilla.de/test-odp-links-agent.html)"

    Where the size (usually after the 200 HTTP status) is zero.

    This occurs when there is a HEAD request. My robots.txt
    file is 0 long, so that likely causes it as well.

    It's strange that it hadn't happened before I upgraded to
    6.6, even though these entries in my logfile have existed
    for a long time.