Source-Changes-HG archive

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

[src/trunk]: src Upgrade indent(1)



details:   https://anonhg.NetBSD.org/src/rev/1035f8ecb6c7
branches:  trunk
changeset: 840369:1035f8ecb6c7
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Apr 04 15:22:13 2019 +0000

description:
Upgrade indent(1)

Merge all the changes from the recent FreeBSD HEAD snapshot
into our local copy.

FreeBSD actively maintains this program in their sources and their
repository contains over 100 commits with changes.

Keep the delta between the FreeBSD and NetBSD versions to absolute
minimum, mostly RCS Id and compatiblity fixes.

Major chages in this import:

 - Added an option -ldi<N> to control indentation of local variable names.
 - Added option -P for loading user-provided files as profiles
 - Added -tsn for setting tabsize
 - Rename -nsac/-sac ("space after cast") to -ncs/-cs
 - Added option -fbs Enables (disables) splitting the function declaration and opening brace across two lines.
 - Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1)
 - Group global option variables into an options structure
 - Use bsearch() for looking up type keywords.
 - Don't produce unneeded space character in function declarators
 - Don't unnecessarily add a blank before a comment ends.
 - Don't ignore newlines after comments that follow braces.

Merge the FreeBSD intend(1) tests with our ATF framework.
All tests pass.

Upgrade prepared by Manikishan Ghantasala.
Final polishing by myself.

diffstat:

 distrib/sets/lists/tests/mi   |    50 +-
 tests/usr.bin/Makefile        |     4 +-
 usr.bin/indent/Makefile       |     4 +-
 usr.bin/indent/README         |     4 +-
 usr.bin/indent/args.c         |   589 ++++-----
 usr.bin/indent/indent.1       |   315 +++--
 usr.bin/indent/indent.c       |  2361 ++++++++++++++++++++--------------------
 usr.bin/indent/indent_codes.h |    46 +-
 usr.bin/indent/indent_globs.h |   480 +++----
 usr.bin/indent/io.c           |   844 ++++++--------
 usr.bin/indent/lexi.c         |  1130 ++++++++++---------
 usr.bin/indent/parse.c        |   459 +++----
 usr.bin/indent/pr_comment.c   |   646 ++++------
 13 files changed, 3323 insertions(+), 3609 deletions(-)

diffs (truncated from 7924 to 300 lines):

diff -r af75001681e9 -r 1035f8ecb6c7 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Apr 04 15:10:58 2019 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Apr 04 15:22:13 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.809 2019/02/26 10:01:40 isaki Exp $
+# $NetBSD: mi,v 1.810 2019/04/04 15:22:13 kamil Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3822,6 +3822,54 @@
 ./usr/tests/usr.bin/id/t_groups                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/id/t_id                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/id/t_whoami                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent                     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/Atffile             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/Kyuafile            tests-usr.bin-tests     compattestfile,atf,kyua
+./usr/tests/usr.bin/indent/t_indent            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/binary.0            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/binary.0.stdout     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/comments.0          tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/comments.0.pro      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/comments.0.stdout   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/cs.0                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/cs.0.pro            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/cs.0.stdout         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/declarations.0      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/declarations.0.stdout       tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/elsecomment.0       tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/elsecomment.0.pro   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/elsecomment.0.stdout        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/f_decls.0           tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/f_decls.0.stdout    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/float.0             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/float.0.stdout      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/label.0             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/label.0.pro         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/label.0.stdout      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/list_head.0         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/list_head.0.stdout  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/ncs.0               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/ncs.0.pro           tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/ncs.0.stdout                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/offsetof.0          tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/offsetof.0.stdout   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/parens.0            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/parens.0.pro                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/parens.0.stdout     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/pcs.0               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/pcs.0.pro           tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/pcs.0.stdout                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/struct.0            tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/struct.0.stdout     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/surplusbad.0                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/surplusbad.0.pro    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/surplusbad.0.stdout tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/types_from_file.0   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/types_from_file.0.list      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/types_from_file.0.pro       tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/types_from_file.0.stdout    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/wchar.0             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/indent/wchar.0.stdout      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/infocmp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/infocmp/Atffile            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/infocmp/Kyuafile           tests-usr.bin-tests     compattestfile,atf,kyua
diff -r af75001681e9 -r 1035f8ecb6c7 tests/usr.bin/Makefile
--- a/tests/usr.bin/Makefile    Thu Apr 04 15:10:58 2019 +0000
+++ b/tests/usr.bin/Makefile    Thu Apr 04 15:22:13 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.26 2018/09/05 21:05:40 kre Exp $
+#      $NetBSD: Makefile,v 1.27 2019/04/04 15:22:13 kamil Exp $
 #
 
 .include <bsd.own.mk>
@@ -6,7 +6,7 @@
 TESTSDIR=       ${TESTSBASE}/usr.bin
 
 TESTS_SUBDIRS= awk basename bzip2 cc cmp config cut \
-               diff dirname find gdb grep gzip id \
+               diff dirname find gdb grep gzip id indent \
                infocmp jot ld m4 make mixerctl mkdep nbperf netpgpverify \
                pkill pr printf rump_server shmif_dumpbus sdiff \
                sed sort tmux tr unifdef uniq vmstat xlint
diff -r af75001681e9 -r 1035f8ecb6c7 usr.bin/indent/Makefile
--- a/usr.bin/indent/Makefile   Thu Apr 04 15:10:58 2019 +0000
+++ b/usr.bin/indent/Makefile   Thu Apr 04 15:22:13 2019 +0000
@@ -1,7 +1,9 @@
-#      $NetBSD: Makefile,v 1.6 2006/10/08 17:52:28 peter Exp $
+#      $NetBSD: Makefile,v 1.7 2019/04/04 15:22:13 kamil Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/6/93
 
 PROG=  indent
 SRCS=  indent.c io.c lexi.c parse.c pr_comment.c args.c
 
+COPTS.io.c += -Wno-error=format-nonliteral
+
 .include <bsd.prog.mk>
diff -r af75001681e9 -r 1035f8ecb6c7 usr.bin/indent/README
--- a/usr.bin/indent/README     Thu Apr 04 15:10:58 2019 +0000
+++ b/usr.bin/indent/README     Thu Apr 04 15:22:13 2019 +0000
@@ -45,7 +45,7 @@
 | Time passed.  Some years later, indent showed up on one of the early
 | emacs distributions.
 | 
-| Later still, someone from UC Berlekey called the UofI and asked if
+| Later still, someone from UC Berkeley called the UofI and asked if
 | indent was in the public domain.  They wanted to include it in their
 | UNIX distributions, along with the emacs stuff.  I was no longer at the
 | UofI, but Rob Kolstad, who was, asked me about it.  I told him I didn't
@@ -67,7 +67,7 @@
 | Berkeley's copyright probably should only cover their changes, and I
 | don't know their feelings about sending it out.  
 
-In any case, there appears to be noone at UofI to clarify/and change
+In any case, there appears to be none at UofI to clarify/and change
 that copyright, but I am confident (based on the statements of its
 author) that the code, as it stands with its copyright, is
 distributable, and will not cause any legal problems.
diff -r af75001681e9 -r 1035f8ecb6c7 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c     Thu Apr 04 15:10:58 2019 +0000
+++ b/usr.bin/indent/args.c     Thu Apr 04 15:22:13 2019 +0000
@@ -1,37 +1,11 @@
-/*     $NetBSD: args.c,v 1.13 2016/02/22 21:20:29 ginsbach Exp $       */
+/*     $NetBSD: args.c,v 1.14 2019/04/04 15:22:13 kamil Exp $  */
 
-/*
+/*-
+ * SPDX-License-Identifier: BSD-4-Clause
+ *
+ * Copyright (c) 1985 Sun Microsystems, Inc.
  * Copyright (c) 1980, 1993
  *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1976 Board of Trustees of the University of Illinois.
- * Copyright (c) 1985 Sun Microsystems, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -63,14 +37,20 @@
  * SUCH DAMAGE.
  */
 
+#if 0
+#ifndef lint
+static char sccsid[] = "@(#)args.c     8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
+#endif
+
 #include <sys/cdefs.h>
 #ifndef lint
-#if 0
-static char sccsid[] = "@(#)args.c     8.1 (Berkeley) 6/6/93";
-#else
-__RCSID("$NetBSD: args.c,v 1.13 2016/02/22 21:20:29 ginsbach Exp $");
+#if defined(__NetBSD__)
+__RCSID("$NetBSD: args.c,v 1.14 2019/04/04 15:22:13 kamil Exp $");
+#elif defined(__FreeBSD__)
+__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
-#endif                         /* not lint */
+#endif
 
 /*
  * Argument scanning and profile reading code.  Default parameters are set
@@ -79,16 +59,19 @@
 
 #include <ctype.h>
 #include <err.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "indent_globs.h"
+#include "indent.h"
+
+#define INDENT_VERSION "2.0"
 
 /* profile types */
 #define        PRO_SPECIAL     1       /* special case */
 #define        PRO_BOOL        2       /* boolean */
 #define        PRO_INT         3       /* integer */
-#define PRO_FONT       4       /* troff font */
 
 /* profile specials for booleans */
 #define        ON              1       /* turn it on */
@@ -100,8 +83,15 @@
 #define        STDIN           3       /* use stdin */
 #define        KEY             4       /* type (keyword) */
 
+static void scan_profile(FILE *);
+
+#define        KEY_FILE                5       /* only used for args */
+#define VERSION                        6       /* only used for args */
+
 const char *option_source = "?";
 
+void add_typedefs_from_file(const char *str);
+
 /*
  * N.B.: because of the way the table here is scanned, options whose names are
  * substrings of other options must occur later; that is, with -lp vs -l, -lp
@@ -109,355 +99,264 @@
  * default value is the one actually assigned.
  */
 struct pro {
-       const char *p_name;     /* name, eg -bl, -cli */
-       int     p_type;         /* type (int, bool, special) */
-       int     p_default;      /* the default value (if int) */
-       int     p_special;      /* depends on type */
-       int    *p_obj;          /* the associated variable */
-}       pro[] = {
-       {
-               "T", PRO_SPECIAL, 0, KEY, 0
-       },
-       {
-               "bacc", PRO_BOOL, false, ON, &blanklines_around_conditional_compilation
-       },
-       {
-               "badp", PRO_BOOL, false, ON, &blanklines_after_declarations_at_proctop
-       },
-       {
-               "bad", PRO_BOOL, false, ON, &blanklines_after_declarations
-       },
-       {
-               "bap", PRO_BOOL, false, ON, &blanklines_after_procs
-       },
-       {
-               "bbb", PRO_BOOL, false, ON, &blanklines_before_blockcomments
-       },
-       {
-               "bc", PRO_BOOL, true, OFF, &ps.leave_comma
-       },
-       {
-               "bl", PRO_BOOL, true, OFF, &btype_2
-       },
-       {
-               "br", PRO_BOOL, true, ON, &btype_2
-       },
-       {
-               "bs", PRO_BOOL, false, ON, &Bill_Shannon
-       },
-       {
-               "cdb", PRO_BOOL, true, ON, &comment_delimiter_on_blankline
-       },
-       {
-               "cd", PRO_INT, 0, 0, &ps.decl_com_ind
-       },
-       {
-               "ce", PRO_BOOL, true, ON, &cuddle_else
-       },
-       {
-               "ci", PRO_INT, 0, 0, &continuation_indent
-       },
-       {
-               "cli", PRO_SPECIAL, 0, CLI, 0
-       },
-       {
-               "c", PRO_INT, 33, 0, &ps.com_ind
-       },
-       {
-               "di", PRO_INT, 16, 0, &ps.decl_indent
-       },
-       {
-               "dj", PRO_BOOL, false, ON, &ps.ljust_decl
-       },
-       {
-               "d", PRO_INT, 0, 0, &ps.unindent_displace
-       },
-       {
-               "eei", PRO_BOOL, false, ON, &extra_expression_indent
-       },
-       {
-               "ei", PRO_BOOL, true, ON, &ps.else_if
-       },
-       {



Home | Main Index | Thread Index | Old Index