mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-06-21 10:18:17 +02:00
fixes a bug with strtol on mac
This commit is contained in:
parent
71e9f4f0af
commit
4576f966af
25
src/boxes.c
25
src/boxes.c
@ -656,25 +656,20 @@ static int process_commandline (int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
pdummy = strchr (optarg, 'x');
|
pdummy = strchr (optarg, 'x');
|
||||||
if (!pdummy) pdummy = strchr (optarg, 'X');
|
if (!pdummy) pdummy = strchr (optarg, 'X');
|
||||||
errno = 0;
|
if(pdummy) {
|
||||||
opt.reqwidth = strtol (optarg, NULL, 10);
|
*pdummy = '\0';
|
||||||
idummy = errno;
|
|
||||||
if (idummy) {
|
|
||||||
fprintf (stderr, "%s: invalid box size specification: %s\n",
|
|
||||||
PROJECT, strerror(idummy));
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
errno = 0;
|
||||||
|
if (optarg != pdummy) opt.reqwidth = strtol (optarg, NULL, 10);
|
||||||
if (pdummy) {
|
if (pdummy) {
|
||||||
errno = 0;
|
|
||||||
opt.reqheight = strtol (pdummy+1, NULL, 10);
|
opt.reqheight = strtol (pdummy+1, NULL, 10);
|
||||||
idummy = errno;
|
*pdummy = 'x';
|
||||||
if (idummy) {
|
}
|
||||||
fprintf (stderr, "%s: invalid box size specification: %s\n",
|
if(errno){
|
||||||
PROJECT, strerror(idummy));
|
fprintf (stderr, "%s: box size: %s, '%s'\n",
|
||||||
|
PROJECT, strerror(idummy), optarg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
} else if ((opt.reqwidth == 0 && opt.reqheight == 0)
|
||||||
}
|
|
||||||
if ((opt.reqwidth == 0 && opt.reqheight == 0)
|
|
||||||
|| opt.reqwidth < 0 || opt.reqheight < 0) {
|
|| opt.reqwidth < 0 || opt.reqheight < 0) {
|
||||||
fprintf (stderr, "%s: invalid box size specification -- %s\n",
|
fprintf (stderr, "%s: invalid box size specification -- %s\n",
|
||||||
PROJECT, optarg);
|
PROJECT, optarg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user