MCPcopy Index your code
hub / github.com/RsyncProject/rsync / longOptionStrcmp

Function longOptionStrcmp

popt/popt.c:301–330  ·  view source on GitHub ↗

* Compare long option for equality, adjusting for POPT_ARGFLAG_TOGGLE. * @param opt option * @param longName arg option * @param longNameLen arg option length * @return does long option match? */

Source from the content-addressed store, hash-verified

299 * @return does long option match?
300 */
301static int
302longOptionStrcmp(const struct poptOption * opt,
303 const char * longName, size_t longNameLen)
304{
305 const char * optLongName = opt->longName;
306 int rc;
307
308 if (optLongName == NULL || longName == NULL) /* XXX can't heppen */
309 return 0;
310
311 if (F_ISSET(opt, TOGGLE)) {
312 if (optLongName[0] == 'n' && optLongName[1] == 'o') {
313 optLongName += sizeof("no") - 1;
314 if (optLongName[0] == '-')
315 optLongName++;
316 }
317 if (longName[0] == 'n' && longName[1] == 'o') {
318 longName += sizeof("no") - 1;
319 longNameLen -= sizeof("no") - 1;
320 if (longName[0] == '-') {
321 longName++;
322 longNameLen--;
323 }
324 }
325 }
326 rc = (int)(strlen(optLongName) == longNameLen);
327 if (rc)
328 rc = (int)(strncmp(optLongName, longName, longNameLen) == 0);
329 return rc;
330}
331
332/* Only one of longName, shortName may be set at a time */
333static int handleAlias(poptContext con,

Callers 2

handleAliasFunction · 0.85
findOptionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected