|
2 | 2 | #include "GArgs.h" |
3 | 3 | #include <ctype.h> |
4 | 4 |
|
5 | | -GArgs::GArgs(int argc, char* const argv[], const char* format, bool nodigitopts) { |
| 5 | +GArgs::GArgs(int argc, char* argv[], const char* format, bool nodigitopts) { |
6 | 6 | /* format can be: |
7 | 7 | <string>{;|=} e.g. disable-test;PID=S= for --disable-test PID=50 (or --PID 50) S=3.5 etc. |
8 | 8 | <letter>[:] e.g. p:hT for -p testing (or -ptesting) -h -T |
@@ -63,20 +63,24 @@ while (fstr-format < fmtlen ) { |
63 | 63 | //-- now parse the arguments based on the given format specification |
64 | 64 | parseArgs(nodigitopts); |
65 | 65 | } |
66 | | - |
| 66 | + |
| 67 | +void dbg_dequote(char* &p) { |
| 68 | + int alen=strlen(p); |
| 69 | + if (alen>1 && p[0]=='\'' && p[alen-1]=='\'') { |
| 70 | + p++; |
| 71 | + p[alen-2 ]='\0'; |
| 72 | + } |
| 73 | +} |
| 74 | + |
67 | 75 | int GArgs::parseArgs(bool nodigitopts) { |
68 | 76 | int p=1; //skip program name |
69 | 77 | int f=0; |
70 | 78 | while (p<_argc) { |
71 | | - /* silly patch for annnoying OSX gdb issues: |
| 79 | + // silly patch for annnoying MacOS gdb/eclipse issues: |
72 | 80 | #if defined(__APPLE__) && defined(DEBUG) |
73 | | - int alen=strlen(_argv[p]); |
74 | | - if (alen>1 && _argv[p][0]=='\'' && _argv[p][alen-1]=='\'') { |
75 | | - _argv[p]++; |
76 | | - _argv[p][alen-1]='\0'; |
77 | | - } |
| 81 | + dbg_dequote(_argv[p]); |
78 | 82 | #endif |
79 | | - */ |
| 83 | + //-- |
80 | 84 | if (_argv[p][0]=='-' && (_argv[p][1]==0 || _argv[p][1]!='-')) { |
81 | 85 | //single-dash argument |
82 | 86 | int cpos=1; |
@@ -119,8 +123,11 @@ int GArgs::parseArgs(bool nodigitopts) { |
119 | 123 | if (_argv[p][cpos+1]=='\0') { |
120 | 124 | if (p+1<_argc && _argv[p+1][0]!=0) { //value is the whole next argument |
121 | 125 | p++; |
| 126 | + #if defined(__APPLE__) && defined(DEBUG) |
| 127 | + dbg_dequote(_argv[p]); |
| 128 | + #endif |
122 | 129 | args[count].value=Gstrdup(_argv[p]); |
123 | | - } |
| 130 | + } |
124 | 131 | else { |
125 | 132 | errarg=p; |
126 | 133 | err_valmissing=true; |
@@ -234,7 +241,7 @@ void GArgs::printCmdLine(FILE* fout) { |
234 | 241 | } |
235 | 242 | } |
236 | 243 |
|
237 | | -GArgs::GArgs(int argc, char* const argv[], const GArgsDef fmtrecs[], bool nodigitopts) { |
| 244 | +GArgs::GArgs(int argc, char* argv[], const GArgsDef fmtrecs[], bool nodigitopts) { |
238 | 245 | fmtcount=0; |
239 | 246 | count=0; |
240 | 247 | nonOptCount=0; |
|
0 commit comments