Changeset 5440c295 in git


Ignore:
Timestamp:
14/01/14 21:24:49 (6 years ago)
Author:
Olly Betts <olly@…>
Branches:
line_contents, master, stereo, travis-osx
Children:
de9aa88
Parents:
c891a7e
Message:

src/aven.cc: Simplify handling of command line under WXMSW,
fixing error if run with no parameters.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rc891a7e r5440c295  
     1Tue Jan 14 21:23:10 GMT 2014  Olly Betts <olly@survex.com>
     2
     3        * src/aven.cc: Simplify handling of command line under __WXMSW__,
     4          fixing error if run with no parameters.
     5
    16Tue Jan 14 21:17:38 GMT 2014  Olly Betts <olly@survex.com>
    27
  • src/aven.cc

    rc891a7e r5440c295  
    55//
    66//  Copyright (C) 2001 Mark R. Shinwell.
    7 //  Copyright (C) 2002,2003,2004,2005,2006,2011,2013 Olly Betts
     7//  Copyright (C) 2002,2003,2004,2005,2006,2011,2013,2014 Olly Betts
    88//
    99//  This program is free software; you can redistribute it and/or modify
     
    8686static int getopt_first_response = 0;
    8787
     88static char ** utf8_argv;
     89
    8890#ifdef __WXMSW__
    8991bool Aven::Initialize(int& my_argc, wxChar **my_argv)
     
    9193    // wxWidgets passes us wxChars, which may be wide characters but cmdline
    9294    // wants UTF-8 so we need to convert.
    93 #ifdef __GNUC__
    94     // This is a GCC extension.
    95     char *utf8_argv[my_argc + 1];
    96 #else
    97     vector<char *> utf8_argv(my_argc + 1);
    98 #endif
     95    utf8_argv = new char * [my_argc + 1];
    9996    for (int i = 0; i < my_argc; ++i){
    10097        utf8_argv[i] = strdup(wxString(my_argv[i]).mb_str());
     
    10299    utf8_argv[my_argc] = NULL;
    103100
    104     msg_init(&utf8_argv[0]);
     101    msg_init(utf8_argv);
    105102    select_charset(CHARSET_UTF8);
    106103    /* Want --version and decent --help output, which cmdline does for us.
     
    108105     */
    109106    cmdline_set_syntax_message(/*[SURVEY_FILE]*/269, 0, NULL);
    110     cmdline_init(my_argc, &utf8_argv[0], short_opts, long_opts, NULL, help, 0, 1);
     107    cmdline_init(my_argc, utf8_argv, short_opts, long_opts, NULL, help, 0, 1);
    111108    getopt_first_response = cmdline_getopt();
    112109    return wxApp::Initialize(my_argc, my_argv);
    113110}
    114111#else
    115 static char ** real_argv;
    116 
    117112int main(int argc, char **argv)
    118113{
     
    137132    getopt_first_response = cmdline_getopt();
    138133
    139     real_argv = argv;
     134    utf8_argv = argv;
    140135
    141136#if wxUSE_UNICODE
     
    183178    bool print_and_exit = false;
    184179
    185 #ifdef __WXMSW__
    186     char ** real_argv = argv;
    187 #endif
    188 
    189180    while (true) {
    190181        int opt;
     
    204195    }
    205196
    206     if (print_and_exit && !real_argv[optind]) {
     197    if (print_and_exit && !utf8_argv[optind]) {
    207198        cmdline_syntax(); // FIXME : not a helpful error...
    208199        exit(1);
     
    210201
    211202    wxString fnm;
    212     if (real_argv[optind]) {
    213         fnm = wxString(real_argv[optind], wxConvUTF8);
    214         if (fnm.empty() && *(real_argv[optind])) {
     203    if (utf8_argv[optind]) {
     204        fnm = wxString(utf8_argv[optind], wxConvUTF8);
     205        if (fnm.empty() && *(utf8_argv[optind])) {
    215206            ReportError(wxT("File argument's filename has bad encoding"));
    216207            return false;
     
    277268    }
    278269
    279     if (real_argv[optind]) {
     270    if (utf8_argv[optind]) {
    280271        m_Frame->OpenFile(fnm, survey);
    281272    }
Note: See TracChangeset for help on using the changeset viewer.