Re: this calls and checks strtol() correctly?



On Sun, 29 Jun 2008 01:51:34 -0700 (PDT), badc0de4@xxxxxxxxx wrote:
You might want to add a test for *endptr != '\0'
If argv[2] contains "443foo", *endptr will be 'f' after the strtol()
call (and port will be 433)

In general (not for argv[2]) you may want to accept trailing
whitespace, e.g. because strtol accepts leading whitespace.


--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
.



Relevant Pages

  • Re: [OT] Vim highlighting for trailing spaces
    ... >> And for vim trailing space, ... > It always displays trailing whitespace and spaces-before tabs... ... want to use pattern below to also highlight "tab after space" in the ...
    (Linux-Kernel)
  • Re: Options for DataTable string comparisons
    ... that is the correct interpretation of the issue: ignoring trailing ... whitespace in key comparisons should be optional. ... I'm aware that DataTable behaves like SQL Server, ... different from other databases' rules (e.g., Oracle). ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: RFC: Trailing blanks in source files
    ... > | notification that it is happening so if for some reason you ... > | do want trailing whitespace you could abort or override. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: [patch] zaurus family: battery cleanups
    ... This patch has a number of checkpatch errors. ... Mostly trailing ... whitespace, or just spacing issues.. ...
    (Linux-Kernel)
  • Re: extracting lines from an address
    ... This method has a couple of minor shortcomings - it does not eliminate all unnecessary whitespace (specifically, it does not look at whitespace at the beginning of the address field - if there were any, nor does it look at trailing whitespace). ... puts "oops... ...
    (comp.lang.ruby)