[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] Add function to convert leading whitespace to tabs
From: |
Erik Lundin |
Subject: |
Re: [Nano-devel] Add function to convert leading whitespace to tabs |
Date: |
Sat, 18 Oct 2014 23:33:56 +0200 |
Thanks for the input. I've attached a revised version. I also made some
simplifying.
On Sat, 2014-10-18 at 14:30 -0400, Mike Frysinger wrote:
> On Sat 18 Oct 2014 09:30:08 Erik Lundin wrote:
> > + /* If the mark is on, use all lines covered by the mark. */
> > + if (openfile->mark_set)
> > + mark_order((const filestruct **)&top, &top_x,
> > + (const filestruct **)&bot, &bot_x, NULL);
> > + /* Otherwise, use the current line. */
> > + else {
>
> this is dangerous -- there really should be braces in the first case
>
True. I copied it from the do_indent() function just above.
> > + /* Calculate how much space the whitespace is using */
>
> you mix style here ... sometimes you have a period at the end and sometimes
> you don't.
>
> > + for(i = 0; i < line_len; i++) {
> > + if(f->data[i] == ' ') {
> > + spaces++;
> > + } else if(f->data[i] == '\t') {
>
> there should be a space after the for & if. this comes up a few times in
> your
> patch.
>
> > + size_t top_x, bot_x, line_len;
> > + int i, spaces, tabs, tabs_needed, ws_len, new_len;
>
> you mix these types below and compare/assign int's to size_t's. you probably
> need to harmonize that.
>
> > + tabs_needed = ((spaces + tabsize - 1)/tabsize) + tabs;
>
> needs spaces around the /
> -mike
I'm getting mixed indents of spaces and tabs i various files. I guess
it's supposed to be all spaces?
--
Erik Lundin <address@hidden>
nano_whitespace_to_tabs_2.patch
Description: Text Data
- [Nano-devel] Add function to convert leading whitespace to tabs, Erik Lundin, 2014/10/18
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Mike Frysinger, 2014/10/18
- Re: [Nano-devel] Add function to convert leading whitespace to tabs,
Erik Lundin <=
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Benno Schulenberg, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Erik Lundin, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Benno Schulenberg, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Erik Lundin, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Benno Schulenberg, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Erik Lundin, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Benno Schulenberg, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Benno Schulenberg, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Erik Lundin, 2014/10/19
- Re: [Nano-devel] Add function to convert leading whitespace to tabs, Ken Tyler, 2014/10/20