www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5610] New: std.getopt.getopt Access Violation

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5610

           Summary: std.getopt.getopt Access Violation
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: golovanov_alexey mail.ru



---
Created an attachment (id=917)
smallest testcase

program using std.getopt and started with non-english option (especially
prepended by '-') crushes with error: object.Error: Access Violation.

Environment:
Windows XP SP3
DMD 2.052

Command line:
getopt_test.exe -файл

Output:
object.Error: Access Violation

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 18 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5610


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |INVALID



19:24:35 PDT ---
I'm testing this on v2.053. I suggest you upgrade to this version, it will give
you nice stacktraces and a more useful error message.

getopt only accepts a single argument with a single dash. You could pass a
single unicode character if you want to e.g.:
getopt_test.exe -ф

And you'll get:
getopt.d(411): Unrecognized option -ф

which just means you have to write the code to handle such a case, but it
works.

Your multi-argument call will work if you prepend two dashes:

import std.getopt;
void main(string[] args)
{
    bool test;
    getopt(args, "файл", &test);
    assert(test);
}

getopt_test.exe --файл

So I'm closing this down, unless you find the bug persists.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 24 2011