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. Part II, checkin new files.
This commit is contained in:
parent
d6a1bc3f07
commit
d845d12b1a
|
@ -0,0 +1,54 @@
|
|||
# $NetBSD: Makefile,v 1.1 2019/04/04 15:27:35 kamil Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/usr.bin/indent
|
||||
TESTS_SH= t_indent
|
||||
|
||||
FILESDIR= ${TESTSDIR}
|
||||
FILES= binary.0
|
||||
FILES+= binary.0.stdout
|
||||
FILES+= comments.0
|
||||
FILES+= comments.0.pro
|
||||
FILES+= comments.0.stdout
|
||||
FILES+= declarations.0
|
||||
FILES+= declarations.0.stdout
|
||||
FILES+= elsecomment.0
|
||||
FILES+= elsecomment.0.stdout
|
||||
FILES+= elsecomment.0.pro
|
||||
FILES+= f_decls.0
|
||||
FILES+= f_decls.0.stdout
|
||||
FILES+= float.0
|
||||
FILES+= float.0.stdout
|
||||
FILES+= label.0
|
||||
FILES+= label.0.stdout
|
||||
FILES+= label.0.pro
|
||||
FILES+= list_head.0
|
||||
FILES+= list_head.0.stdout
|
||||
FILES+= ncs.0
|
||||
FILES+= ncs.0.stdout
|
||||
FILES+= ncs.0.pro
|
||||
FILES+= offsetof.0
|
||||
FILES+= offsetof.0.stdout
|
||||
FILES+= parens.0
|
||||
FILES+= parens.0.stdout
|
||||
FILES+= parens.0.pro
|
||||
FILES+= pcs.0
|
||||
FILES+= pcs.0.stdout
|
||||
FILES+= pcs.0.pro
|
||||
FILES+= cs.0
|
||||
FILES+= cs.0.stdout
|
||||
FILES+= cs.0.pro
|
||||
FILES+= struct.0
|
||||
FILES+= struct.0.stdout
|
||||
FILES+= surplusbad.0
|
||||
FILES+= surplusbad.0.stdout
|
||||
FILES+= surplusbad.0.pro
|
||||
FILES+= types_from_file.0
|
||||
FILES+= types_from_file.0.stdout
|
||||
FILES+= types_from_file.0.list
|
||||
FILES+= types_from_file.0.pro
|
||||
FILES+= wchar.0
|
||||
FILES+= wchar.0.stdout
|
||||
|
||||
.include <bsd.test.mk>
|
|
@ -0,0 +1,11 @@
|
|||
/* $NetBSD: binary.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/binary.0 318471 2017-05-18 17:15:58Z pstef $ */
|
||||
#define b00101010 -1
|
||||
void t(void) {
|
||||
unsigned a[] = {0b00101010, 0x00005678, 02, 17U};
|
||||
float x[] = {.7f, 0.7f};
|
||||
unsigned long ul[] = {0b00001111UL, 0x01010101UL, 02UL, 17UL};
|
||||
|
||||
if (0 b00101010)
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/* $NetBSD: binary.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/binary.0.stdout 321381 2017-07-23 14:04:45Z pstef $ */
|
||||
#define b00101010 -1
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
unsigned a[] = {0b00101010, 0x00005678, 02, 17U};
|
||||
float x[] = {.7f, 0.7f};
|
||||
unsigned long ul[] = {0b00001111UL, 0x01010101UL, 02UL, 17UL};
|
||||
|
||||
if (0 b00101010)
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/* $NetBSD: comments.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/comments.0 321383 2017-07-23 15:07:52Z pstef $ */
|
||||
typedef enum x {
|
||||
aaaaaaaaaaaaaaaaaaaaaa = 1 << 0, /* test a */
|
||||
bbbbbbbbbbbbbbbbb = 1 << 1, /* test b */
|
||||
cccccccccccccc = 1 << 1, /* test c */
|
||||
dddddddddddddddddddddddddddddd = 1 << 2 /* test d */
|
||||
} x;
|
||||
|
||||
/* See r303597, r303598, r309219, and r309343 */
|
||||
void t(void) {
|
||||
/*
|
||||
* Old indent wrapped the URL near where this sentence ends.
|
||||
*
|
||||
* https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
|
||||
*/
|
||||
|
||||
/*
|
||||
* Old indent did not wrap to column 78
|
||||
*
|
||||
* aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj kk
|
||||
*/
|
||||
|
||||
/*
|
||||
* Old indent unnecessarily removed the star comment continuation on the next line.
|
||||
*
|
||||
* *test*
|
||||
*/
|
||||
|
||||
/* r309219 Go through linked list, freeing from the malloced (t[-1]) address. */
|
||||
|
||||
/* r309343 */
|
||||
}
|
||||
|
||||
int c(void)
|
||||
{
|
||||
if (1) { /*- a christmas tree *
|
||||
***
|
||||
***** */
|
||||
/*- another one *
|
||||
***
|
||||
***** */
|
||||
7;
|
||||
}
|
||||
|
||||
if (1) /*- a christmas tree *
|
||||
***
|
||||
***** */
|
||||
/*- another one *
|
||||
***
|
||||
***** */
|
||||
1;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: comments.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/comments.0.pro 321383 2017-07-23 15:07:52Z pstef $ */
|
||||
-bbb
|
|
@ -0,0 +1,61 @@
|
|||
/* $NetBSD: comments.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/comments.0.stdout 334563 2018-06-03 15:28:55Z pstef $ */
|
||||
typedef enum x {
|
||||
aaaaaaaaaaaaaaaaaaaaaa = 1 << 0, /* test a */
|
||||
bbbbbbbbbbbbbbbbb = 1 << 1, /* test b */
|
||||
cccccccccccccc = 1 << 1, /* test c */
|
||||
dddddddddddddddddddddddddddddd = 1 << 2 /* test d */
|
||||
} x;
|
||||
|
||||
/* See r303597, r303598, r309219, and r309343 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
/*
|
||||
* Old indent wrapped the URL near where this sentence ends.
|
||||
*
|
||||
* https://www.freebsd.org/cgi/man.cgi?query=indent&apropos=0&sektion=0&manpath=FreeBSD+12-current&arch=default&format=html
|
||||
*/
|
||||
|
||||
/*
|
||||
* Old indent did not wrap to column 78
|
||||
*
|
||||
* aaaaaa bbbbbb cccccc dddddd eeeeee ffffff ggggg hhhhh iiiii jjjj
|
||||
* kk
|
||||
*/
|
||||
|
||||
/*
|
||||
* Old indent unnecessarily removed the star comment continuation on
|
||||
* the next line.
|
||||
*
|
||||
* *test*
|
||||
*/
|
||||
|
||||
/*
|
||||
* r309219 Go through linked list, freeing from the malloced (t[-1])
|
||||
* address.
|
||||
*/
|
||||
|
||||
/* r309343 */
|
||||
}
|
||||
|
||||
int
|
||||
c(void)
|
||||
{
|
||||
if (1) { /*- a christmas tree *
|
||||
***
|
||||
***** */
|
||||
/*- another one *
|
||||
***
|
||||
***** */
|
||||
7;
|
||||
}
|
||||
|
||||
if (1) /*- a christmas tree *
|
||||
***
|
||||
***** */
|
||||
/*- another one *
|
||||
***
|
||||
***** */
|
||||
1;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
/* $NetBSD: cs.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/cs.0 334944 2018-06-11 05:35:57Z pstef $ */
|
||||
void t(void) {
|
||||
int a = (double) 8;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: cs.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/cs.0.pro 334944 2018-06-11 05:35:57Z pstef $ */
|
||||
-cs
|
|
@ -0,0 +1,7 @@
|
|||
/* $NetBSD: cs.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/cs.0.stdout 334944 2018-06-11 05:35:57Z pstef $ */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int a = (double) 8;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/* $NetBSD: declarations.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
|
||||
/* See r303570 */
|
||||
|
||||
typedef void (*voidptr) (int *);
|
||||
|
||||
static const struct
|
||||
{
|
||||
double x;
|
||||
double y, z;
|
||||
} n[m + 1] =
|
||||
{
|
||||
{
|
||||
.0,
|
||||
.9,
|
||||
5
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct Complex
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
} Complex;
|
||||
|
||||
void
|
||||
t1 (char *a, int b,
|
||||
void (*fn)(void))
|
||||
{}
|
||||
|
||||
void t2 (char *x, int y)
|
||||
{
|
||||
int a,
|
||||
b,
|
||||
c;
|
||||
int
|
||||
*d,
|
||||
*e,
|
||||
*f;
|
||||
int (*g)(),
|
||||
(*h)(),
|
||||
(*i)();
|
||||
int j,
|
||||
k,
|
||||
l;
|
||||
int m
|
||||
,n
|
||||
,o
|
||||
;
|
||||
int chars[ /* push the comma beyond column 74 .... */ ], x;
|
||||
}
|
||||
|
||||
const int int_minimum_size =
|
||||
MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF;
|
||||
|
||||
int *int_create(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
_attribute_printf(1, 2)
|
||||
void
|
||||
print_error(const char *fmt,...)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static LIST_HEAD(, alq) ald_active;
|
||||
static int ald_shutingdown = 0;
|
||||
struct thread *ald_thread;
|
||||
|
||||
static int
|
||||
do_execve(td, args, mac_p)
|
||||
struct thread *td;
|
||||
struct image_args *args;
|
||||
struct mac *mac_p;
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* $NetBSD: declarations.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/declarations.0.stdout 334480 2018-06-01 09:58:44Z pstef $ */
|
||||
/* See r303570 */
|
||||
|
||||
typedef void (*voidptr) (int *);
|
||||
|
||||
static const struct {
|
||||
double x;
|
||||
double y, z;
|
||||
} n[m + 1] =
|
||||
{
|
||||
{
|
||||
.0,
|
||||
.9,
|
||||
5
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct Complex {
|
||||
double x;
|
||||
double y;
|
||||
} Complex;
|
||||
|
||||
void
|
||||
t1(char *a, int b,
|
||||
void (*fn) (void))
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
t2(char *x, int y)
|
||||
{
|
||||
int a, b, c;
|
||||
int
|
||||
*d, *e, *f;
|
||||
int (*g) (), (*h) (), (*i) ();
|
||||
int j, k, l;
|
||||
int m
|
||||
,n
|
||||
,o
|
||||
;
|
||||
int chars[ /* push the comma beyond column 74 .... */ ],
|
||||
x;
|
||||
}
|
||||
|
||||
const int int_minimum_size =
|
||||
MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF;
|
||||
|
||||
int *
|
||||
int_create(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
_attribute_printf(1, 2)
|
||||
void
|
||||
print_error(const char *fmt,...)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static LIST_HEAD(, alq) ald_active;
|
||||
static int ald_shutingdown = 0;
|
||||
struct thread *ald_thread;
|
||||
|
||||
static int
|
||||
do_execve(td, args, mac_p)
|
||||
struct thread *td;
|
||||
struct image_args *args;
|
||||
struct mac *mac_p;
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/* $NetBSD: elsecomment.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/elsecomment.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
|
||||
/* See r303484 and r309342 */
|
||||
void t(void) {
|
||||
/* The two if statements below excercise two different code paths. */
|
||||
|
||||
if (1) /* a */ int a; else /* b */ int b;
|
||||
|
||||
if (1) /* a */
|
||||
int a;
|
||||
else /* b */
|
||||
int b;
|
||||
|
||||
if (1) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Old indent would remove the 3 blank lines above, awaiting "else". */
|
||||
|
||||
if (1) {
|
||||
int a;
|
||||
}
|
||||
|
||||
|
||||
else if (0) {
|
||||
int b;
|
||||
}
|
||||
/* test */
|
||||
else
|
||||
;
|
||||
|
||||
if (1)
|
||||
;
|
||||
else /* Old indent would get very confused here */
|
||||
/* We also mustn't assume that there's only one comment */
|
||||
/* before the left brace. */
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: elsecomment.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/elsecomment.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
|
||||
-bl
|
|
@ -0,0 +1,48 @@
|
|||
/* $NetBSD: elsecomment.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/elsecomment.0.stdout 334559 2018-06-03 14:03:20Z pstef $ */
|
||||
/* See r303484 and r309342 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
/* The two if statements below excercise two different code paths. */
|
||||
|
||||
if (1) /* a */
|
||||
int a;
|
||||
else /* b */
|
||||
int b;
|
||||
|
||||
if (1) /* a */
|
||||
int a;
|
||||
else /* b */
|
||||
int b;
|
||||
|
||||
if (1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Old indent would remove the 3 blank lines above, awaiting "else". */
|
||||
|
||||
if (1)
|
||||
{
|
||||
int a;
|
||||
} else if (0)
|
||||
{
|
||||
int b;
|
||||
}
|
||||
/* test */
|
||||
else
|
||||
;
|
||||
|
||||
if (1)
|
||||
;
|
||||
else /* Old indent would get very confused here */
|
||||
/* We also mustn't assume that there's only one comment */
|
||||
/* before the left brace. */
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* $NetBSD: f_decls.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/f_decls.0 334566 2018-06-03 16:42:58Z pstef $ */
|
||||
|
||||
char * x(void)
|
||||
{
|
||||
type identifier;
|
||||
type *pointer;
|
||||
unused * value;
|
||||
(void)unused * value;
|
||||
|
||||
dmax = (double)3 * 10.0;
|
||||
dmin = (double)dmax * 10.0;
|
||||
davg = (double)dmax * dmin;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int *
|
||||
y(void) {
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
z(void) {
|
||||
|
||||
}
|
||||
|
||||
int x;
|
||||
int *y;
|
||||
int * * * * z;
|
|
@ -0,0 +1,33 @@
|
|||
/* $NetBSD: f_decls.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/f_decls.0.stdout 334566 2018-06-03 16:42:58Z pstef $ */
|
||||
|
||||
char *
|
||||
x(void)
|
||||
{
|
||||
type identifier;
|
||||
type *pointer;
|
||||
unused *value;
|
||||
(void)unused * value;
|
||||
|
||||
dmax = (double)3 * 10.0;
|
||||
dmin = (double)dmax * 10.0;
|
||||
davg = (double)dmax * dmin;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int *
|
||||
y(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
z(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int x;
|
||||
int *y;
|
||||
int ****z;
|
|
@ -0,0 +1,9 @@
|
|||
/* $NetBSD: float.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/float.0 337862 2018-08-15 18:19:45Z pstef $ */
|
||||
void t(void) {
|
||||
unsigned long x = 314UL;
|
||||
double y[] = {0x1P+9F, 0.3, .1, 1.2f, 0xa.p01f, 3.14f, 2.L};
|
||||
int z = 0b0101;
|
||||
DO_NOTHING;
|
||||
x._y = 5;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
/* $NetBSD: float.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/float.0.stdout 337862 2018-08-15 18:19:45Z pstef $ */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
unsigned long x = 314UL;
|
||||
double y[] = {0x1P+9F, 0.3, .1, 1.2f, 0xa.p01f, 3.14f, 2.L};
|
||||
int z = 0b0101;
|
||||
DO_NOTHING;
|
||||
x._y = 5;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
/* $NetBSD: label.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/label.0 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r303489 */
|
||||
void t(void) {
|
||||
switch (1)
|
||||
{
|
||||
case 1: /* test */
|
||||
case 2: /* test */
|
||||
}
|
||||
CLEANUP:
|
||||
;
|
||||
V: ;
|
||||
U: ;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: label.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/label.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
|
||||
-nut
|
|
@ -0,0 +1,15 @@
|
|||
/* $NetBSD: label.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/label.0.stdout 321381 2017-07-23 14:04:45Z pstef $ */
|
||||
/* See r303489 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
switch (1) {
|
||||
case 1: /* test */
|
||||
case 2: /* test */
|
||||
}
|
||||
CLEANUP:
|
||||
;
|
||||
V: ;
|
||||
U: ;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
/* $NetBSD: list_head.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/list_head.0 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r309380 */
|
||||
static int
|
||||
do_execve(td, args, mac_p)
|
||||
struct thread *td;
|
||||
struct image_args *args;
|
||||
struct mac *mac_p;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static LIST_HEAD(, alq) ald_active;
|
||||
static int ald_shuttingdown = 0;
|
||||
struct thread *ald_thread;
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/* $NetBSD: list_head.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/list_head.0.stdout 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r309380 */
|
||||
static int
|
||||
do_execve(td, args, mac_p)
|
||||
struct thread *td;
|
||||
struct image_args *args;
|
||||
struct mac *mac_p;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static LIST_HEAD(, alq) ald_active;
|
||||
static int ald_shuttingdown = 0;
|
||||
struct thread *ald_thread;
|
|
@ -0,0 +1,5 @@
|
|||
/* $NetBSD: ncs.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/ncs.0 334944 2018-06-11 05:35:57Z pstef $ */
|
||||
void t(void) {
|
||||
int a = (double) 8;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: ncs.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/ncs.0.pro 334944 2018-06-11 05:35:57Z pstef $ */
|
||||
-ncs
|
|
@ -0,0 +1,7 @@
|
|||
/* $NetBSD: ncs.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/ncs.0.stdout 334944 2018-06-11 05:35:57Z pstef $ */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int a = (double)8;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
/* $NetBSD: offsetof.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/offsetof.0 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r303718 */
|
||||
void t(void) {
|
||||
int n = malloc(offsetof(struct s, f) + 1);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
/* $NetBSD: offsetof.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/offsetof.0.stdout 321381 2017-07-23 14:04:45Z pstef $ */
|
||||
/* See r303718 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
int n = malloc(offsetof(struct s, f) + 1);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* $NetBSD: parens.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/parens.0 334583 2018-06-03 19:05:20Z pstef $ */
|
||||
typedef void (*xxxxxxxxxxx) (int,
|
||||
char);
|
||||
|
||||
typedef char (*xxxxxxxxxxxxxxxxxxxxxxxxxxxx) (int *,
|
||||
unsigned *,
|
||||
char,
|
||||
float *);
|
||||
|
||||
void
|
||||
test(void)
|
||||
{
|
||||
char chars[secondf(firstf(B),
|
||||
*here)];
|
||||
|
||||
float xxx = yyyyyyyyyyyyyy(zzzzzzzzzzzzz(p1,
|
||||
(p2),
|
||||
p3));
|
||||
|
||||
if (1) {
|
||||
char *xxx = firstf(secondf2(p1,
|
||||
p2));
|
||||
}
|
||||
|
||||
rb->allocfunc(1);
|
||||
rb2.allocfunc(7);
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: parens.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/parens.0.pro 334583 2018-06-03 19:05:20Z pstef $ */
|
||||
-ts4 -i4 -di12 -Tallocfunc
|
|
@ -0,0 +1,28 @@
|
|||
/* $NetBSD: parens.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/parens.0.stdout 334583 2018-06-03 19:05:20Z pstef $ */
|
||||
typedef void (*xxxxxxxxxxx) (int,
|
||||
char);
|
||||
|
||||
typedef char (*xxxxxxxxxxxxxxxxxxxxxxxxxxxx) (int *,
|
||||
unsigned *,
|
||||
char,
|
||||
float *);
|
||||
|
||||
void
|
||||
test(void)
|
||||
{
|
||||
char chars[secondf(firstf(B),
|
||||
*here)];
|
||||
|
||||
float xxx = yyyyyyyyyyyyyy(zzzzzzzzzzzzz(p1,
|
||||
(p2),
|
||||
p3));
|
||||
|
||||
if (1) {
|
||||
char *xxx = firstf(secondf2(p1,
|
||||
p2));
|
||||
}
|
||||
|
||||
rb->allocfunc(1);
|
||||
rb2.allocfunc(7);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
/* $NetBSD: pcs.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/pcs.0 334493 2018-06-01 19:56:41Z pstef $ */
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
puts("Hello");
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: pcs.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/pcs.0.pro 334493 2018-06-01 19:56:41Z pstef $ */
|
||||
-pcs
|
|
@ -0,0 +1,10 @@
|
|||
/* $NetBSD: pcs.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/pcs.0.stdout 334493 2018-06-01 19:56:41Z pstef $ */
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
puts ("Hello");
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/* $NetBSD: struct.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/struct.0 334564 2018-06-03 16:21:15Z pstef $ */
|
||||
|
||||
int f(struct x *a);
|
||||
|
||||
/* See r303485 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
static const struct {
|
||||
int a;
|
||||
int b;
|
||||
} c[] = {
|
||||
{ D, E },
|
||||
{ F, G }
|
||||
};
|
||||
}
|
||||
|
||||
void u(struct x a) {
|
||||
int b;
|
||||
struct y c = (struct y *)&a;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* $NetBSD: struct.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/struct.0.stdout 334564 2018-06-03 16:21:15Z pstef $ */
|
||||
|
||||
int f(struct x *a);
|
||||
|
||||
/* See r303485 */
|
||||
void
|
||||
t(void)
|
||||
{
|
||||
static const struct {
|
||||
int a;
|
||||
int b;
|
||||
} c[] = {
|
||||
{D, E},
|
||||
{F, G}
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
u(struct x a)
|
||||
{
|
||||
int b;
|
||||
struct y c = (struct y *)&a;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/* $NetBSD: surplusbad.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/surplusbad.0 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r303599 */
|
||||
#if defined(__i386__)
|
||||
int a;
|
||||
#elif defined(__amd64__)
|
||||
int b;
|
||||
#else
|
||||
#error "Port me"
|
||||
#endif
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: surplusbad.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/surplusbad.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
|
||||
-bad
|
|
@ -0,0 +1,10 @@
|
|||
/* $NetBSD: surplusbad.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/surplusbad.0.stdout 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r303599 */
|
||||
#if defined(__i386__)
|
||||
int a;
|
||||
#elif defined(__amd64__)
|
||||
int b;
|
||||
#else
|
||||
#error "Port me"
|
||||
#endif
|
|
@ -0,0 +1,91 @@
|
|||
#
|
||||
# Copyright 2016 Dell EMC
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * 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.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
# OWNER 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.
|
||||
#
|
||||
# $FreeBSD: head/usr.bin/indent/tests/functional_test.sh 314613 2017-03-03 20:15:22Z ngie $
|
||||
|
||||
SRCDIR=$(atf_get_srcdir)
|
||||
|
||||
check()
|
||||
{
|
||||
local tc=${1}; shift
|
||||
|
||||
local indent=$(atf_config_get usr.bin.indent.test_indent /usr/bin/indent)
|
||||
|
||||
# All of the files need to be in the ATF sandbox in order for the tests
|
||||
# to pass.
|
||||
atf_check cp ${SRCDIR}/${tc}* .
|
||||
|
||||
# Remove $FreeBSD: head/usr.bin/indent/tests/functional_test.sh 314613 2017-03-03 20:15:22Z ngie $ RCS expansions because they get re-indented, which
|
||||
# changes the output
|
||||
local out_file="${tc}.stdout"
|
||||
if [ -f "${out_file}" ]; then
|
||||
parsed_file=output_file.parsed
|
||||
|
||||
atf_check -o save:$parsed_file sed -e '/\$NetBSD.*\$/,/\$FreeBSD.*\$/d' \
|
||||
${tc}.stdout
|
||||
out_flag="-o file:$parsed_file"
|
||||
fi
|
||||
local profile_file="${tc}.pro"
|
||||
if [ -f "${profile_file}" ]; then
|
||||
profile_flag="-P${profile_file}"
|
||||
else
|
||||
# Make sure we don't implicitly use ~/.indent.pro from the test
|
||||
# host, for determinism purposes.
|
||||
profile_flag="-npro"
|
||||
fi
|
||||
sed -e '/\$NetBSD.*\$/,/\$FreeBSD.*\$/d' ${tc} > input_file.parsed
|
||||
|
||||
atf_check -s exit:${tc##*.} ${out_flag} ${indent} ${profile_flag} < input_file.parsed
|
||||
}
|
||||
|
||||
add_testcase()
|
||||
{
|
||||
local tc=${1}
|
||||
local tc_escaped word
|
||||
|
||||
case "${tc%.*}" in
|
||||
*-*)
|
||||
local IFS="-"
|
||||
for word in ${tc%.*}; do
|
||||
tc_escaped="${tc_escaped:+${tc_escaped}_}${word}"
|
||||
done
|
||||
;;
|
||||
*)
|
||||
tc_escaped=${tc%.*}
|
||||
;;
|
||||
esac
|
||||
|
||||
atf_test_case ${tc_escaped}
|
||||
eval "${tc_escaped}_body() { check ${tc}; }"
|
||||
atf_add_test_case ${tc_escaped}
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
for path in $(find -Es "${SRCDIR}" -regex '.*\.[0-9]+$'); do
|
||||
add_testcase ${path##*/}
|
||||
done
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: types_from_file.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/types_from_file.0 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r303735 */
|
||||
void t(a *x, b *y, c *z);
|
|
@ -0,0 +1,2 @@
|
|||
b
|
||||
a
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: types_from_file.0.pro,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/types_from_file.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
|
||||
-Utypes_from_file.0.list
|
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: types_from_file.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/types_from_file.0.stdout 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r303735 */
|
||||
void t(a *x, b *y, c * z);
|
|
@ -0,0 +1,7 @@
|
|||
/* $NetBSD: wchar.0,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/wchar.0 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r309220 */
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *x = L"test";
|
||||
wchar_t y = L't';
|
|
@ -0,0 +1,7 @@
|
|||
/* $NetBSD: wchar.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
/* $FreeBSD: head/usr.bin/indent/tests/wchar.0.stdout 313544 2017-02-10 09:31:39Z pstef $ */
|
||||
/* See r309220 */
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *x = L"test";
|
||||
wchar_t y = L't';
|
|
@ -0,0 +1,60 @@
|
|||
/* $NetBSD: indent.h,v 1.1 2019/04/04 15:27:35 kamil Exp $ */
|
||||
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2001 Jens Schweikhardt
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#if defined(__NetBSD__)
|
||||
__RCSID("$NetBSD: indent.h,v 1.1 2019/04/04 15:27:35 kamil Exp $");
|
||||
#elif defined(__FreeBSD__)
|
||||
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef nitems
|
||||
#define nitems(array) (sizeof (array) / sizeof (array[0]))
|
||||
#endif
|
||||
|
||||
void add_typename(const char *);
|
||||
void alloc_typenames(void);
|
||||
int compute_code_target(void);
|
||||
int compute_label_target(void);
|
||||
int count_spaces(int, char *);
|
||||
int count_spaces_until(int, char *, char *);
|
||||
void init_constant_tt(void);
|
||||
int lexi(struct parser_state *);
|
||||
void diag2(int, const char *);
|
||||
void diag3(int, const char *, int);
|
||||
void diag4(int, const char *, int, int);
|
||||
void dump_line(void);
|
||||
void fill_buffer(void);
|
||||
void parse(int);
|
||||
void pr_comment(void);
|
||||
void set_defaults(void);
|
||||
void set_option(char *);
|
||||
void set_profile(const char *);
|
Loading…
Reference in New Issue