buggnokii - Bugs: bug #18532, Options after --getsms are not...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #18532: Options after --getsms are not parsed

Submitted by:  None
Submitted on:  Fri 15 Dec 2006 08:20:50 PM UTC  
 
Category: gnokiiSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Pawel Kot <pkot>
Open/Closed: Closed

Sat 16 Dec 2006 07:08:20 PM UTC, comment #5:

Probably you are right, Linux getopt manpage says:

By default, getopt() permutes the contents of argv as it scans, so that eventually all the non-options are at the end. Two other modes are also implemented. If the first character of optstring is ’+’ or the environment variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-option argument is encountered.

That explains why it worked on Linux and that it is not POSIXLY_CORRECT.

Pawel Kot <pkot>
Project AdministratorIn charge of this item.
Sat 16 Dec 2006 06:58:52 PM UTC, comment #4:

Hello again!

IEEE Std 1003.1 seems to be quite clear:

"If, when getopt() is called:

[...]
*argv[optind] is not the character -
[...]

getopt() shall return -1 without changing optind."

Found at:

http://www.opengroup.org/onlinepubs/009695399/functions/getopt.html

Does it mean, Linux (glibc actually) is not POSIX compliant? ts, ts, ts... runandhide ;-)

Dirk Froemberg <ibex>
Sat 16 Dec 2006 05:49:56 PM UTC, comment #3:

Well, I am not convinced. I still think that we call it in POSIX compliant way. But what you say makes sense. If after your patch it still works under Linux I'll apply it.

Pawel Kot <pkot>
Project AdministratorIn charge of this item.
Sat 16 Dec 2006 04:37:10 PM UTC, comment #2:

I'd say gnokii makes assumptions about getopt() on FreeBSD it doesn't fulfill. ;-p

On line 77 to 81 of getopt.c -1 is returned if the arguments given to getopt() don't start with '-'. See for details:

http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/getopt.c?rev=HEAD&content-type=text/x-cvsweb-markup

Before calling getopt() in getsms() optind is 3 actually thus "pointing" to the starting message number, which - of course - doesn't start with '-'. So getopt() on FreeBSD assumes there are no options.

Increasing optind by 1 or 2 (depending on whether a ending message number is given) helps, too. Since getsms() is the only place where getopt() is used instead of getopt_long() I changed it to work around interoperability problems. :-)

Hope this helps...

Anonymous
Fri 15 Dec 2006 10:37:49 PM UTC, comment #1:

I'd say in that case, this is FreeBSD getopt implementation bug, not gnokii. Could you elaborate why the code is not correct?

Pawel Kot <pkot>
Project AdministratorIn charge of this item.
Fri 15 Dec 2006 08:20:50 PM UTC, original submission:

Hi!

At least on FreeBSD options after for --getsms are not parsed correctly, e. g.

In

gnokii --getsms SM 1 -d

"-d" is ignored and no short message is deleted.

The attached patch changes gnokii-sms.c so getopt_long() instead of getopt() is used. Options are recognized correctly with getopt_long().

Anonymous

 

Attached Files
file #11533:  gnokii-sms.c.patch.txt added by None (1010B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ibex (Posted a comment)
  • -unavailable- added by pkot (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 16 Dec 2006 05:59:23 PM UTCpkotStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Sat 16 Dec 2006 05:49:56 PM UTCpkotStatusNeed Info=>In Progress
      Assigned toNone=>pkot
    Fri 15 Dec 2006 10:37:49 PM UTCpkotStatusNone=>Need Info
    Fri 15 Dec 2006 08:20:50 PM UTCNoneAttached File-=>Added gnokii-sms.c.patch.txt, #11533

    Back to the top


    Powered by Savane 3.1-cleanup1