Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent indent: parse options in a platform-independe...



details:   https://anonhg.NetBSD.org/src/rev/907061a729a5
branches:  trunk
changeset: 1024603:907061a729a5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 29 19:52:59 2021 +0000

description:
indent: parse options in a platform-independent way

Previously, on an ILP32 platform, the option '-ts30000000000000000'
resulted in the error message 'must be an integer', on LP64 platforms it
resulted in the error message 'must be between 1 and 80'. Remove this
unnecessary difference.

diffstat:

 usr.bin/indent/args.c |  8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 3e944f4af422 -r 907061a729a5 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Fri Oct 29 19:39:32 2021 +0000
+++ b/usr.bin/indent/args.c     Fri Oct 29 19:52:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: args.c,v 1.66 2021/10/28 22:20:08 rillig Exp $ */
+/*     $NetBSD: args.c,v 1.67 2021/10/29 19:52:59 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.66 2021/10/28 22:20:08 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.67 2021/10/29 19:52:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -52,7 +52,6 @@
 
 #include <ctype.h>
 #include <err.h>
-#include <errno.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -241,10 +240,9 @@
        return;
     }
 
-    errno = 0;
     char *end;
     long num = strtol(arg_arg, &end, 10);
-    if (!(errno == 0 && *end == '\0'))
+    if (*end != '\0')
        errx(1, "%s: argument \"%s\" to option \"-%s\" must be an integer",
            option_source, arg_arg, p->p_name);
 



Home | Main Index | Thread Index | Old Index