Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Bracket/Indentation-style converter

Name: Anonymous 2010-10-10 13:43

Greetings /prog/

As you are aware there is a plethora of brackets/indentation styles in the dicipline of programming.

http://en.wikipedia.org/wiki/Indentation_style

My opinion is that the Allman style is better than any other. Other styles are inferior to Allman style in regards of readability and I would prefer to work with code in Allman style only.

Thus, I find the need for a utility to convert the text in a set of files into the Allman style necessary.

Would any of you know if such a utility exists? Is there even an extention to emacs that could do this?

Name: Anonymous 2010-10-10 13:48

indent(1)

Name: Anonymous 2010-10-10 14:16

>>1
No, because Allman style is widely considered to be shit.

Name: Anonymous 2010-10-10 14:40

main() {
  printf("Lisp-style indentation is superior.");}

Name: Anonymous 2010-10-10 14:45

>>4
printf considered harmful, use puts.

Name: Anonymous 2010-10-10 14:52

>>5
printf with format string.

Name: Anonymous 2010-10-10 14:53

>>5
Not for string constants.

Name: Anonymous 2010-10-10 14:59

#include <stdio.h>

int
main(argc, argv)
     int argc;
     char **argv;
{ printf("Best indentation style.\n");
  return 0; }

Name: Anonymous 2010-10-10 16:47

I never paid any attention to it, but I seem to use a variation of Allman style.  I don't space between method names and their argument parentheses, occasionally I mash comma-parameters together and arithmetic operators closer, the latter usually in the case of index calculation.  I also sometimes one-line certain statements.

int vagueExample(int x, int y)
{
   if(y < 0) return something(x,y); // 'for' and 'while' loops too
   else y = somethingElse(x);
   return something(x,y);
}

Name: Anonymous 2010-10-10 17:17

>>9
My spacings are semantic:

foo[x +1];             // simple offset
bar[offset * recsize]; // offset calculation
baz[off1 + off2];      // or: baz[off1+off2]; // offset sum
qux(x,y);              // coords/vectors
quux(aleph, beth);     // distinct parameters


etc.

Name: Anonymous 2010-10-10 17:21

So nobody does this:
int foo (int x, int y) {
    /* ... */
}

consistently?

Name: Anonymous 2010-10-10 17:29

>>11

I do.

Name: >>10 2010-10-10 17:32

>>11
I do. Only people who don't do it feel the need to make a fuss over it.

Name: Anonymous 2010-10-10 17:34

>>11
That's a pretty dumb thing to do.

Name: Anonymous 2010-10-10 17:43

lol religion

Name: Anonymous 2010-10-10 17:44

K&R style > you

Name: Anonymous 2010-10-10 17:48

>>12,13
Oh, okay.
>>14
Please elaborate

Name: Anonymous 2010-10-10 18:10

PIG DISGUSTING. K&R or else get the fuck out.

Name: Anonymous 2010-10-10 18:56

>>18
no u

Name: Anonymous 2010-10-10 21:25

Faggots who complain about the extra line used in an Allman opening bracket need to refactor their code more.

Name: Anonymous 2010-10-10 22:45

Allman is shit. KNF or take your shitty code elsewhere.

Name: Anonymous 2010-10-10 23:03

Allman style -> Stallman style
You are now enlightened.

Name: Anonymous 2010-10-10 23:06

>>21
There are several indentation styles nicknamed KNF, which K are you referring to?

Name: Anonymous 2010-10-10 23:09

It seems that people in this thread CAN be bigger elitist jerks than already originally assumed possible in /prog/.

Name: Anonymous 2010-10-10 23:15

If I'm just reading, I don't care how other people indent (as long as it's not flush-left, or something equally dumb and useless like GNU style), but the moment I have to change something, I run astyle -A10 -s8.

Name: Anonymous 2010-10-11 1:08

>>23
Kernighan 'n' Fichie.

Name: Anonymous 2010-10-11 2:34

My style? (The else part is a bit forced for completeness' sake.)


/*
    hax :: String -> String -> Int
    Takes an anus along with a compatible signal
    and applies a codan determined by the signal.
*/
int hax(char *anus, char *signal)
{
    int i;
    signal *sig;

    sig = SIGMORPH(signal);
    for(i=0; i<ANII; i++)
        hax_helper(anus);
    if(good_enough(anus, sig))
    {
        apply_codan(anus, sig); // TODO: Handle codan errors.
        printf("%s\n", "OK.");
        return 0;
    }
    else
    {
        printf("Faulty anus %s\n.", anus);
        return 1;
    }
}

Name: Anonymous 2011-02-04 12:10


Don't change these.
Name: Email:
Entire Thread Thread List