Commit 53f1a33d5e570fe886ec91551d0198686b352daa
1 parent
e57e637d
poprawienie segfaulta przy końcu programu
git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/morfeusz@139 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing
4 changed files
with
10 additions
and
8 deletions
morfeusz/cli/cli.cpp
... | ... | @@ -12,9 +12,9 @@ static inline void printCLIUsage(ezOptionParser& opt, ostream& out) { |
12 | 12 | out << usage; |
13 | 13 | } |
14 | 14 | |
15 | -ezOptionParser getOptions(int argc, const char** argv, const string& titleText) { | |
15 | +ezOptionParser* getOptions(int argc, const char** argv, const string& titleText) { | |
16 | 16 | |
17 | - ezOptionParser opt; | |
17 | + ezOptionParser& opt = *(new ezOptionParser()); | |
18 | 18 | |
19 | 19 | opt.overview = titleText; |
20 | 20 | opt.syntax = string(argv[0]) + " [OPTIONS]"; |
... | ... | @@ -83,10 +83,10 @@ ezOptionParser getOptions(int argc, const char** argv, const string& titleText) |
83 | 83 | printCLIUsage(opt, cout); |
84 | 84 | exit(0); |
85 | 85 | } |
86 | - return opt; | |
86 | + return &opt; | |
87 | 87 | } |
88 | 88 | |
89 | -void initializeMorfeusz(ezOptionParser opt, Morfeusz& morfeusz) { | |
89 | +void initializeMorfeusz(ezOptionParser& opt, Morfeusz& morfeusz) { | |
90 | 90 | if (opt.isSet("-i")) { |
91 | 91 | string analyzerFile; |
92 | 92 | opt.get("-i")->getString(analyzerFile); |
... | ... |
morfeusz/cli/cli.hpp
... | ... | @@ -35,8 +35,8 @@ |
35 | 35 | |
36 | 36 | #include "ezOptionParser.hpp" |
37 | 37 | |
38 | -ez::ezOptionParser getOptions(int argc, const char** argv, const string& titleText); | |
39 | -void initializeMorfeusz(ez::ezOptionParser opt, Morfeusz& morfeusz); | |
38 | +ez::ezOptionParser* getOptions(int argc, const char** argv, const string& titleText); | |
39 | +void initializeMorfeusz(ez::ezOptionParser& opt, Morfeusz& morfeusz); | |
40 | 40 | |
41 | 41 | #pragma GCC diagnostic pop |
42 | 42 | |
... | ... |
morfeusz/morfeusz_analyzer.cpp
... | ... | @@ -20,7 +20,7 @@ using namespace std; |
20 | 20 | |
21 | 21 | int main(int argc, const char** argv) { |
22 | 22 | |
23 | - ez::ezOptionParser opt = getOptions(argc, argv, "Morfeusz analyzer"); | |
23 | + ez::ezOptionParser& opt = *getOptions(argc, argv, "Morfeusz analyzer"); | |
24 | 24 | Morfeusz morfeusz; |
25 | 25 | initializeMorfeusz(opt, morfeusz); |
26 | 26 | // Morfeusz morfeusz(getMorfeuszFromCLI(argc, argv, "Morfeusz analyzer")); |
... | ... | @@ -53,5 +53,6 @@ int main(int argc, const char** argv) { |
53 | 53 | printf("]\n"); |
54 | 54 | } |
55 | 55 | printf("\n"); |
56 | + delete &opt; | |
56 | 57 | return 0; |
57 | 58 | } |
... | ... |
morfeusz/morfeusz_generator.cpp
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | using namespace std; |
18 | 18 | |
19 | 19 | int main(int argc, const char** argv) { |
20 | - ez::ezOptionParser opt = getOptions(argc, argv, "Morfeusz analyzer"); | |
20 | + ez::ezOptionParser& opt = *getOptions(argc, argv, "Morfeusz analyzer"); | |
21 | 21 | Morfeusz morfeusz; |
22 | 22 | initializeMorfeusz(opt, morfeusz); |
23 | 23 | string line; |
... | ... | @@ -36,5 +36,6 @@ int main(int argc, const char** argv) { |
36 | 36 | printf("]\n"); |
37 | 37 | } |
38 | 38 | printf("\n"); |
39 | + delete &opt; | |
39 | 40 | return 0; |
40 | 41 | } |
... | ... |