[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] global: convert indentation-TABs to spaces
From: |
Jim Meyering |
Subject: |
[PATCH 1/5] global: convert indentation-TABs to spaces |
Date: |
Sun, 23 Aug 2009 00:22:21 +0200 |
FYI, here's a patch series I've been planning for some time.
Yes, it looks disruptive, but I can demonstrate[*] that even
if you have significant patches relative to pre-conversion code,
it's not hard to migrate them mechanically so that they
apply cleanly to the post-conversion code.
I haven't decided precisely when to push this, but suspect
it will be very soon.
[1/5] global: convert indentation-TABs to spaces
[2/5] maint: teach "make syntax-check" the space-only indentation rule
[3/5] doc: HACKING: mention the new space-only indentation policy
[4/5] maint: remove Local Variables: indent-tabs-mode: nil from all sources
[5/5] maint: ensure we don't embed Emacs indent-tabs-mode setting lines
[*] demo coming, eventually.
>From dea5400b9df3af1a593dd4f39b8834dbd8c37932 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 22 Aug 2009 18:56:06 +0200
Subject: [PATCH 1/5] global: convert indentation-TABs to spaces
Transformed via this shell code:
t=$'\t'
git ls-files \
| grep -vE '(^|/)((GNU)?[Mm]akefile|ChangeLog)|\.(am|mk)$' \
| grep -vE 'tests/pr/|help2man' \
| xargs grep -lE "^ *$t" \
| xargs perl -MText::Tabs -ni -le \
'$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
---
.gitmodules | 4 +-
HACKING | 4 +-
build-aux/cvsu | 450 ++++----
configure.ac | 24 +-
gl/lib/mgetgroups.c | 68 +-
gl/lib/rand-isaac.c | 18 +-
gl/lib/randint.c | 132 +-
gl/lib/randperm.c | 24 +-
gl/lib/randread.c | 66 +-
gl/lib/root-dev-ino.h | 10 +-
gl/lib/tempname.c | 126 +-
gl/lib/tempname.h | 4 +-
gl/lib/xfreopen.c | 10 +-
lib/buffer-lcm.c | 32 +-
lib/euidaccess-stat.c | 24 +-
lib/fdopendir-glibc.c | 14 +-
lib/memxfrm.c | 50 +-
lib/strnumcmp-in.h | 144 +-
lib/strnumcmp.c | 2 +-
lib/t-chdir-long | 8 +-
lib/xfts.c | 26 +-
lib/xfts.h | 2 +-
lib/xmemxfrm.c | 6 +-
m4/include-exclude-prog.m4 | 10 +-
m4/jm-macros.m4 | 28 +-
m4/lib-check.m4 | 4 +-
m4/stat-prog.m4 | 28 +-
m4/xattr.m4 | 12 +-
old/fileutils/NEWS | 8 +-
src/base64.c | 162 ++--
src/basename.c | 8 +-
src/c99-to-c89.diff | 72 +-
src/cat.c | 700 +++++-----
src/chcon.c | 322 +++---
src/chgrp.c | 162 ++--
src/chmod.c | 308 +++---
src/chown-core.c | 350 +++---
src/chown-core.h | 6 +-
src/chown.c | 174 ++--
src/chroot.c | 8 +-
src/cksum.c | 36 +-
src/comm.c | 222 ++--
src/copy.c | 2080 +++++++++++++++---------------
src/copy.h | 4 +-
src/cp-hash.c | 6 +-
src/cp.c | 1004 +++++++-------
src/csplit.c | 536 ++++----
src/cut.c | 614 +++++-----
src/date.c | 320 +++---
src/dd.c | 852 ++++++------
src/df.c | 560 ++++----
src/dircolors.c | 310 +++---
src/dircolors.hin | 2 +-
src/dirname.c | 8 +-
src/du.c | 618 +++++-----
src/echo.c | 214 ++--
src/env.c | 76 +-
src/expand.c | 296 +++---
src/expr.c | 338 +++---
src/extract-magic | 6 +-
src/factor.c | 170 ++--
src/fmt.c | 302 +++---
src/fold.c | 214 ++--
src/head.c | 716 +++++-----
src/hostid.c | 4 +-
src/hostname.c | 10 +-
src/id.c | 118 +-
src/install.c | 408 +++---
src/join.c | 584 +++++-----
src/kill.c | 172 ++--
src/link.c | 12 +-
src/ln.c | 384 +++---
src/logname.c | 4 +-
src/ls.c | 2978 +++++++++++++++++++++---------------------
src/md5sum.c | 446 ++++----
src/mkdir.c | 72 +-
src/mkfifo.c | 40 +-
src/mknod.c | 98 +-
src/mv.c | 256 ++--
src/nice.c | 74 +-
src/nl.c | 292 ++--
src/nohup.c | 90 +-
src/od.c | 1328 ++++++++++----------
src/paste.c | 462 ++++----
src/pathchk.c | 256 ++--
src/pinky.c | 208 ++--
src/pr.c | 1538 +++++++++++-----------
src/printenv.c | 48 +-
src/printf.c | 506 ++++----
src/ptx.c | 1462 +++++++++++-----------
src/pwd.c | 122 +-
src/readlink.c | 58 +-
src/remove.c | 948 +++++++-------
src/remove.h | 6 +-
src/rm.c | 218 ++--
src/rmdir.c | 104 +-
src/runcon.c | 134 +-
src/seq.c | 242 ++--
src/shred.c | 664 +++++-----
src/shuf.c | 196 ++--
src/sleep.c | 26 +-
src/sort.c | 2298 ++++++++++++++++----------------
src/split.c | 358 +++---
src/stat.c | 464 ++++----
src/stty.c | 914 +++++++-------
src/su.c | 112 +-
src/sum.c | 70 +-
src/sync.c | 4 +-
src/system.h | 32 +-
src/tac-pipe.c | 84 +-
src/tac.c | 328 +++---
src/tail.c | 1114 ++++++++--------
src/tee.c | 64 +-
src/test.c | 312 +++---
src/touch.c | 294 +++---
src/tr.c | 1306 +++++++++---------
src/true.c | 14 +-
src/tsort.c | 418 +++---
src/tty.c | 24 +-
src/uname.c | 192 ++--
src/unexpand.c | 396 +++---
src/uniq.c | 362 +++---
src/unlink.c | 6 +-
src/uptime.c | 50 +-
src/users.c | 18 +-
src/wc.c | 644 +++++-----
src/wheel-gen.pl | 38 +-
src/who.c | 396 +++---
src/whoami.c | 6 +-
src/yes.c | 18 +-
tests/Coreutils.pm | 522 ++++----
tests/CuTmpdir.pm | 8 +-
tests/chgrp/basic | 2 +-
tests/chmod/usage | 2 +-
tests/chown/separator | 4 +-
tests/cp/cp-mv-backup | 2 +-
tests/cp/perm | 64 +-
tests/cp/same-file | 80 +-
tests/df/total-verify | 14 +-
tests/du/files0-from | 2 +-
tests/ls/stat-vs-dirent | 6 +-
tests/misc/base64 | 40 +-
tests/misc/basename | 6 +-
tests/misc/comm | 10 +-
tests/misc/date | 18 +-
tests/misc/date-next-dow | 4 +-
tests/misc/dirname | 6 +-
tests/misc/expr | 6 +-
tests/misc/factor | 8 +-
tests/misc/head-elide-tail | 56 +-
tests/misc/help-version | 8 +-
tests/misc/ls-misc | 94 +-
tests/misc/md5sum | 44 +-
tests/misc/od | 2 +-
tests/misc/pwd-long | 4 +-
tests/misc/seq | 6 +-
tests/misc/sha1sum | 34 +-
tests/misc/sha224sum | 6 +-
tests/misc/sha256sum | 10 +-
tests/misc/sha384sum | 10 +-
tests/misc/sha512sum | 10 +-
tests/misc/sort-files0-from | 4 +-
tests/misc/sort-merge | 12 +-
tests/misc/sort-version | 156 ++--
tests/misc/stat-printf | 8 +-
tests/misc/stty | 6 +-
tests/misc/sum | 4 +-
tests/misc/tee | 12 +-
tests/misc/test | 38 +-
tests/misc/tty-eof | 30 +-
tests/misc/uniq | 52 +-
tests/misc/wc-files0-from | 4 +-
tests/mkdir/perm | 4 +-
tests/mv/part-symlink | 122 +-
tests/rm/fail-eperm | 166 ++--
tests/touch/dangling-symlink | 4 +-
176 files changed, 19864 insertions(+), 19864 deletions(-)
...54K lines of diffs elided...
>From c306195b2012e058ba019e8737fc360a828889c9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 27 Feb 2009 17:32:19 +0100
Subject: [PATCH 2/5] maint: teach "make syntax-check" the space-only
indentation rule
* cfg.mk (sc_prohibit_tab_based_indentation): New rule.
* .x-sc_prohibit_tab_based_indentation: New file.
* Makefile.am (syntax_check_exceptions): Add file,
.x-sc_prohibit_tab_based_indentation.
---
.x-sc_prohibit_tab_based_indentation | 6 ++++++
Makefile.am | 1 +
cfg.mk | 6 ++++++
3 files changed, 13 insertions(+), 0 deletions(-)
create mode 100644 .x-sc_prohibit_tab_based_indentation
diff --git a/.x-sc_prohibit_tab_based_indentation
b/.x-sc_prohibit_tab_based_indentation
new file mode 100644
index 0000000..2f5d921
--- /dev/null
+++ b/.x-sc_prohibit_tab_based_indentation
@@ -0,0 +1,6 @@
+^GNUMakefile$
+Makefile\.am$
+\.mk$
+^tests/pr/
+ChangeLog.*
+^man/help2man$
diff --git a/Makefile.am b/Makefile.am
index e6a880d..57b3e33 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,6 +49,7 @@ syntax_check_exceptions = \
.x-sc_prohibit_atoi_atof \
.x-sc_prohibit_stat_st_blocks \
.x-sc_prohibit_strcmp \
+ .x-sc_prohibit_tab_based_indentation \
.x-sc_require_config_h \
.x-sc_require_config_h_first \
.x-sc_space_tab \
diff --git a/cfg.mk b/cfg.mk
index 05dbb39..b63e76b 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -206,4 +206,10 @@ sc_strftime_check:
rm -f address@hidden address@hidden;
\
fi
+# Indent only with spaces.
+sc_prohibit_tab_based_indentation:
+ @re='^ * ' \
+ msg='TAB in indentation; use only spaces' \
+ $(_prohibit_regexp)
+
include $(srcdir)/dist-check.mk
--
1.6.4.378.g88f2f
>From 65635556fa4306d098939ab01db7225ccc1e6197 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 27 Feb 2009 17:10:19 +0100
Subject: [PATCH 3/5] doc: HACKING: mention the new space-only indentation policy
---
HACKING | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/HACKING b/HACKING
index 928f0c5..b14b604 100644
--- a/HACKING
+++ b/HACKING
@@ -233,20 +233,25 @@ Try to make the summary line fit one of the following
forms:
maint: change-description
-Use SPACE-only indentation in new files.
-========================================
-In any new file, eliminate all leading TABs (e.g., via running GNU indent
-with --no-tabs) and put these lines at the end of the file:
-[FIXME: suggest vim syntax to do same thing, if it can be done safely.
- Most distros now "set nomodeline" by default for a good reason. ]
+Use SPACE-only indentation in all[*] files
+==========================================
+We use space-only indentation in nearly all files.
+If you use Emacs and your coreutils working directory name matches,
+this code enables the right mode:
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
+ ;; In coreutils, indent with spaces everywhere (not TABs).
+ ;; Exceptions: Makefile and ChangeLog modes.
+ (add-hook 'find-file-hook '(lambda ()
+ (if (and buffer-file-name
+ (string-match "/coreutils\\>" (buffer-file-name))
+ (not (string-equal mode-name "Change Log"))
+ (not (string-equal mode-name "Makefile")))
+ (setq indent-tabs-mode nil))))
-Do not change TABs to spaces or vice versa in any existing file.
+[*] Makefile and ChangeLog files are exempt, of course.
+
+[FIXME: suggest vim syntax to do same thing, if it can be done safely.
+ Most distros now "set nomodeline" by default for a good reason. ]
Send patches to the address listed in --help output
--
1.6.4.378.g88f2f
>From eef8d8f234158da4c8dd35516b5d84a9e08427c8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 27 Feb 2009 17:15:43 +0100
Subject: [PATCH 4/5] maint: remove Local Variables: indent-tabs-mode: nil from
all sources
* src/getlimits.c: Likewise.
* src/group-list.c: Likewise.
* src/groups.c: Likewise.
* src/mktemp.c: Likewise.
* src/setuidgid.c: Likewise.
* src/stdbuf.c: Likewise.
* src/timeout.c: Likewise.
* src/truncate.c: Likewise.
* gl/lib/mbsalign.c: Likewise.
* tests/test-lib.sh: Likewise.
* bootstrap: Likewise.
* README-hacking: Likewise.
---
README-hacking | 4 ----
bootstrap | 4 ----
gl/lib/mbsalign.c | 5 -----
src/getlimits.c | 6 ------
src/group-list.c | 6 ------
src/groups.c | 6 ------
src/mktemp.c | 6 ------
src/setuidgid.c | 6 ------
src/stdbuf.c | 6 ------
src/timeout.c | 6 ------
src/truncate.c | 6 ------
tests/test-lib.sh | 4 ----
12 files changed, 0 insertions(+), 65 deletions(-)
diff --git a/README-hacking b/README-hacking
index b72e54c..daaa4b1 100644
--- a/README-hacking
+++ b/README-hacking
@@ -64,7 +64,3 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Local Variables:
-indent-tabs-mode: nil
-End:
diff --git a/bootstrap b/bootstrap
index 4b5d649..1f1bc4a 100755
--- a/bootstrap
+++ b/bootstrap
@@ -765,7 +765,3 @@ sed 's,\.\./\.\.,..,g' $m > $m-t
mv -f $m-t $m
echo "$0: done. Now you can run './configure'."
-
-# Local Variables:
-# indent-tabs-mode: nil
-# End:
diff --git a/gl/lib/mbsalign.c b/gl/lib/mbsalign.c
index bf90e05..0dfda75 100644
--- a/gl/lib/mbsalign.c
+++ b/gl/lib/mbsalign.c
@@ -229,8 +229,3 @@ mbsalign_cleanup:
return ret;
}
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/getlimits.c b/src/getlimits.c
index da0c6f4..82cd345 100644
--- a/src/getlimits.c
+++ b/src/getlimits.c
@@ -172,9 +172,3 @@ main (int argc, char **argv)
print_int (INTMAX);
print_int (UINTMAX);
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/group-list.c b/src/group-list.c
index 46895b4..4c5391d 100644
--- a/src/group-list.c
+++ b/src/group-list.c
@@ -113,9 +113,3 @@ print_group (gid_t gid, bool use_name)
printf ("%s", grp->gr_name);
return ok;
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/groups.c b/src/groups.c
index c89e0dc..27e8724 100644
--- a/src/groups.c
+++ b/src/groups.c
@@ -124,9 +124,3 @@ main (int argc, char **argv)
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/mktemp.c b/src/mktemp.c
index 43ea416..a9a8708 100644
--- a/src/mktemp.c
+++ b/src/mktemp.c
@@ -286,9 +286,3 @@ main (int argc, char **argv)
exit (status);
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/setuidgid.c b/src/setuidgid.c
index 7d8ca3f..43aa164 100644
--- a/src/setuidgid.c
+++ b/src/setuidgid.c
@@ -214,9 +214,3 @@ main (int argc, char **argv)
exit (exit_status);
}
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/stdbuf.c b/src/stdbuf.c
index 5da9341..3ba5a51 100644
--- a/src/stdbuf.c
+++ b/src/stdbuf.c
@@ -378,9 +378,3 @@ main (int argc, char **argv)
exit (exit_status);
}
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/timeout.c b/src/timeout.c
index 405ae98..20efddd 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -330,9 +330,3 @@ main (int argc, char **argv)
return status;
}
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/src/truncate.c b/src/truncate.c
index 31b3aa6..0cb7b35 100644
--- a/src/truncate.c
+++ b/src/truncate.c
@@ -416,9 +416,3 @@ main (int argc, char **argv)
return errors ? EXIT_FAILURE : EXIT_SUCCESS;
}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 1174d98..ad7a0e9 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -387,7 +387,3 @@ elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 >
/dev/null; then
else
compare() { cmp "$@"; }
fi
-
-# Local Variables:
-# indent-tabs-mode: nil
-# End:
--
1.6.4.378.g88f2f
>From 5c311b439f0285e8197eab3c987985f7163cc906 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 14 Jun 2009 14:21:02 +0200
Subject: [PATCH 5/5] maint: ensure we don't embed Emacs indent-tabs-mode
setting lines
Now that we prohibit indentation via TABs, there's no need for
Emacs indent-tabs-mode setting lines, so prohibit those, too.
* cfg.mk (sc_prohibit_emacs__indent_tabs_mode__setting): New rule.
---
cfg.mk | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index b63e76b..57f211b 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -212,4 +212,10 @@ sc_prohibit_tab_based_indentation:
msg='TAB in indentation; use only spaces' \
$(_prohibit_regexp)
+# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
+sc_prohibit_emacs__indent_tabs_mode__setting:
+ @re='^( *[*#] *)?indent-tabs-mode:' \
+ msg='use of emacs indent-tabs-mode: setting' \
+ $(_prohibit_regexp)
+
include $(srcdir)/dist-check.mk
--
1.6.4.378.g88f2f
- [PATCH 1/5] global: convert indentation-TABs to spaces,
Jim Meyering <=