diff options
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/krb5-c-style.el | 4 | ||||
| -rw-r--r-- | src/util/krb5-mark-cstyle.py | 47 |
2 files changed, 49 insertions, 2 deletions
diff --git a/src/util/krb5-c-style.el b/src/util/krb5-c-style.el index b060e8803..f99791719 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 000000000..f4b4a83e6 --- /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]) |
