bug-indent
[Top][All Lists]
Advanced

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

Bug report: indent confused by nested if


From: James Allwright
Subject: Bug report: indent confused by nested if
Date: Tue, 26 Sep 2023 12:34:18 +0000 (UTC)

Hi,

Sorry for the previous e-mail which I didn't mean to send.
I have found what I believe is a bug in indent. I am doing

indent -br -bli0 -ce -ci2 -cli2 -i2 -l80 -nbap -nut -npsl example2.c -o bug2.c

The file example2.c looks like this:

static void show_indent_bug()
{
  if (global.default_length == -1) {
    if (((float) time_num)/time_denom < 0.75) {
      global.default_length = 16;
    } else {
      global.default_length = 8;
    };
  };
  p = head;
  while ((p != NULL)) {
    if (p->default_length == -1) p->default_length=global.default_length;
    p = p->next;
  };
}


But the output looks like this:

static void show_indent_bug ()
{
  if (global.default_length == -1) {
    if (((float) time_num) / time_denom < 0.75) {
                                                 global.default_length =
                                                 16;} else {
                                                 global.default_length = 8;};};
                                                 p = head; while ((p != NULL)) {
                                                 if (p->default_length ==
                                                     -1) p->default_length =
                                                 global.default_length;
                                                 p = p->next;};}


I have downloaded and compiled version 2.2.13 of indent, but I
still see the problem with this latest version.

Regards,

James Allwright


reply via email to

[Prev in Thread] Current Thread [Next in Thread]