summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorTom Yu <tlyu@mit.edu>2009-11-04 00:21:35 +0000
committerTom Yu <tlyu@mit.edu>2009-11-04 00:21:35 +0000
commit7be2ef2b6c8c491781251a5023db48d7690f5fa8 (patch)
treefb2cd85088bee63fdbca8d20bc2191988f00780e /src/util
parent46a475692087e8e46a924024363f0683bb07e19e (diff)
downloadkrb5-7be2ef2b6c8c491781251a5023db48d7690f5fa8.tar.gz
krb5-7be2ef2b6c8c491781251a5023db48d7690f5fa8.tar.xz
krb5-7be2ef2b6c8c491781251a5023db48d7690f5fa8.zip
Correct regexps for matching emacs and cc-mode versions. In reindent
targets, chdir to SRCTOP to avoid excessive references to $(SRCTOP) in the find script. Define new variables to avoid errors when creating exception lists for find scripts. Use a python script instead of elisp to mark files. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23125 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r--src/util/krb5-c-style.el4
-rw-r--r--src/util/krb5-mark-cstyle.py47
2 files changed, 49 insertions, 2 deletions
diff --git a/src/util/krb5-c-style.el b/src/util/krb5-c-style.el
index b060e8803a..f99791719c 100644
--- a/src/util/krb5-c-style.el
+++ b/src/util/krb5-c-style.el
@@ -48,8 +48,8 @@
;; emacs-23.x has a buggy cc-mode that incorrectly deals with case
;; labels with character constants.
-(if (and (string-match "^23\." emacs-version)
+(if (and (string-match "^23\\." emacs-version)
(require 'cc-defs)
- (string-match "5.31.[0-7]" c-version))
+ (string-match "5\\.31\\.[0-7]" c-version))
(let ((load-path (cons (file-name-directory load-file-name) load-path)))
(load "krb5-hack-cc-mode-caselabel")))
diff --git a/src/util/krb5-mark-cstyle.py b/src/util/krb5-mark-cstyle.py
new file mode 100644
index 0000000000..f4b4a83e6b
--- /dev/null
+++ b/src/util/krb5-mark-cstyle.py
@@ -0,0 +1,47 @@
+from optparse import OptionParser
+import os
+import re
+import sys
+
+styles = {
+ "bsd":
+ "/* -*- mode: c; c-file-style: \"bsd\"; indent-tabs-mode: t -*- */\n",
+ "krb5":
+ "/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */\n"
+ }
+
+def dofile(fname, style):
+ changed = False
+ newname = fname + ".new"
+ infile = open(fname)
+ outfile = open(newname, "w")
+ first = infile.next()
+ if (first != style):
+ changed = True
+ outfile.write(style)
+ if re.match(r"""\s*/\*\s*-\*-.*-\*-\s*\*/""", first):
+ # Replace first line if it was already a local variables line.
+ pass
+ else:
+ outfile.write(first)
+
+ # Simply copy remaining lines.
+ for line in infile:
+ outfile.write(line)
+
+ infile.close()
+ outfile.close()
+
+ if changed:
+ os.rename(newname, fname)
+ else:
+ os.remove(newname)
+
+parser = OptionParser()
+parser.add_option("--cstyle", action="store", dest="style",
+ choices=("bsd", "krb5"), default="krb5")
+(options, args) = parser.parse_args()
+
+for fname in args:
+ print fname
+ dofile(fname, styles[options.style])