From: Junio C Hamano Date: Fri, 03 Feb 2012 22:59:29 GMT Subject: Re: [PATCH v4 03/13] parseopt: make OPT_INTEGER support hexadecimal as well Message-ID: <7vaa4zmsku.fsf@alter.siamese.dyndns.org> In-Reply-To: <1328276078-27955-4-git-send-email-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > - *(int *)opt->value = strtol(arg, (char **)&s, 10); > + if (!prefixcmp(arg, "0x") || !prefixcmp(arg, "0X")) > + *(int *)opt->value = strtol(arg + 2, (char **)&s, 16); > + else > + *(int *)opt->value = strtol(arg, (char **)&s, 10); Can't you just do "strtol(arg, (char **)&s, 0)" instead?