about summary refs log tree commit diff stats
path: root/src/tools/parser.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-07-20 15:33:19 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-20 15:33:19 +0200
commit86281072f9b943c23119f1c90cd33934caf1d737 (patch)
treee6109de8096bc23298f1346b49f2053cc407ac03 /src/tools/parser.c
parentc5c969a9295abe688ad7fd9afce430bae5df910c (diff)
downloadprofani-tty-86281072f9b943c23119f1c90cd33934caf1d737.tar.gz
Use parse_args_with_freetext() for `/correct`
This commit partly reverts
8f37afcd37ad8663ca36c13ca7fbc4a431119f73
Which was using a wrong approach to achieve this.

It changed parse_args() to have a -1 for infinite parameters.
But actually parse_args_with_freetext() should have been used exactly
for this behaviour.

Discovered when checking for
https://github.com/profanity-im/profanity/issues/1404
Diffstat (limited to 'src/tools/parser.c')
-rw-r--r--src/tools/parser.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/parser.c b/src/tools/parser.c
index 240d5358..2e1d5c98 100644
--- a/src/tools/parser.c
+++ b/src/tools/parser.c
@@ -48,7 +48,7 @@
  *
  * inp - The line of input
  * min - The minimum allowed number of arguments
- * max - The maximum allowed number of arguments, -1 for infinite
+ * max - The maximum allowed number of arguments
  *
  * Returns - An NULL terminated array of strings representing the arguments
  * of the command, or NULL if the validation fails.
@@ -135,7 +135,7 @@ parse_args(const char* const inp, int min, int max, gboolean* result)
     int num = g_slist_length(tokens) - 1;
 
     // if num args not valid return NULL
-    if ((num < min) || ((max != -1) && (num > max))) {
+    if ((num < min) || (num > max)) {
         g_slist_free_full(tokens, free);
         g_free(copy);
         *result = FALSE;
d='n175' href='#n175'>175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353