/
| 283 | |
| 284 | /*****************************************************************************/ |
| 285 | size_t pj_trim_argc (char *args) { |
| 286 | /****************************************************************************** |
| 287 | Trim all unnecessary whitespace (and non-essential syntactic tokens) from the |
| 288 | argument string, args, and count its number of elements. |
| 289 | ******************************************************************************/ |
| 290 | size_t i, m, n; |
| 291 | pj_shrink (args); |
| 292 | n = strlen (args); |
| 293 | if (n==0) |
| 294 | return 0; |
| 295 | bool in_string = false; |
| 296 | for (i = m = 0; i < n; i++) { |
| 297 | if (in_string ) { |
| 298 | if( args[i] == '"' && args[i+1] == '"' ) { |
| 299 | i++; |
| 300 | } else if( args[i] == '"' ) { |
| 301 | in_string = false; |
| 302 | } |
| 303 | } |
| 304 | else if (args[i] == '=' && args[i+1] == '"' ) { |
| 305 | i++; |
| 306 | in_string = true; |
| 307 | } |
| 308 | else if (' '==args[i]) { |
| 309 | args[i] = 0; |
| 310 | m++; |
| 311 | } |
| 312 | } |
| 313 | return m + 1; |
| 314 | } |
| 315 | |
| 316 | |
| 317 |
no test coverage detected