public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Kegel <dank@kegel.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] kernel source spellchecker
Date: Wed, 26 Feb 2003 22:59:33 -0800	[thread overview]
Message-ID: <3E5DB755.20707@kegel.com> (raw)

Since the main remaining feature before release of the 2.6
kernel is fixing all the remaining spelling errors,
this patch seems appropriate.  This is against 2.4 but
should apply to other versions as well.
It's not very smart, but should help get us to our
all-important goal of 100% correctly spellt kernel source.
Todo: make it ignore names from the MAINTAINERS file,
the list of signals and syscalls, and other well-known
english words seem mostly in Webster's Posix edition;
rewrite in Perl rather than C, or add real Makefile entry.
Enjoy!
- Dan

--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ linux/scripts/spellcheck-kernel	2003-02-26 22:51:46.000000000 -0800
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Script to spellcheck kernel.
+# usage: spellcheck-kernel [ sourcedir ]
+#     The source directory defaults to /usr/src/linux.
+# e.g.
+#   scripts/spellcheck-kernel .
+#      Check spelling of the kernel tree in the current directory
+
+sourcedir=${1-/usr/src/linux}
+
+make -C .. scripts/lspell
+find $sourcedir -name '*.[ch]' | xargs ./lspell
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ linux/scripts/lspell.c	2003-02-26 22:51:14.000000000 -0800
@@ -0,0 +1,74 @@
+/*
+ * C comment spell checker
+ * For each given source file, print the filename, then
+ * extract all comments from the file, send them through the system
+ * spellchecker, sort the list of words flagged as misspellings,
+ * and word-wrap the sorted list.
+ * Copyright 2003, Dan Kegel.  Licensed under GPL.  See the file ../COPYING for details.
+ */
+#include <stdio.h>
+int
+main(int argc, char **argv)
+{
+	int argi;
+
+	for (argi = 1; argi < argc; argi++) {
+		int c;
+		enum state_t { NONCOMMENT, SLASH, COMMENT, STAR, EOLCOMMENT };
+		enum state_t state = NONCOMMENT;
+		FILE *fp = fopen(argv[argi], "rt");
+		if (!fp) {
+			perror(argv[argi]);
+			continue;
+		}
+		FILE *pout = popen("/usr/bin/spell | sort -f | fmt", "w");
+		if (!pout) {
+			perror("/usr/bin/spell | sort -f | fmt");
+			exit(1);
+		}
+		printf("\n%s:\n", argv[argi]);
+		fflush(stdout);
+		while ((c = getc(fp)) != EOF) {
+			switch (state) {
+			case NONCOMMENT:
+				if (c == '/')
+					state = SLASH;
+				break;
+			case SLASH:
+				if (c == '*')
+					state = COMMENT;
+				else if (c == '/')
+					state = EOLCOMMENT;
+				else {
+					state = NONCOMMENT;
+				}
+				break;
+			case COMMENT:
+				if (c == '*')
+					state = STAR;
+				else
+					fputc(c, pout);
+				break;
+			case STAR:
+				if (c == '/')
+					state = NONCOMMENT;
+				else {
+					if (c != '*') {
+						fputc('\n', pout);
+						state = COMMENT;
+					}
+				}
+				break;
+			case EOLCOMMENT:
+				if (c == '\n')
+					state = NONCOMMENT;
+				else
+					fputc(c, pout);
+				break;
+			}
+		}
+		fclose(pout);
+		fclose(fp);
+	}
+	exit(0);
+}

-- 
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045


             reply	other threads:[~2003-02-27  6:40 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-27  6:59 Dan Kegel [this message]
     [not found] ` <1046330232.15763.97.camel@localhost.localdomain>
2003-03-01  5:38   ` [PATCH] kernel source spellchecker Dan Kegel
2003-03-01 14:11     ` Matthias Schniedermeyer
2003-03-01 17:13       ` Matthias Schniedermeyer
2003-03-01 18:54       ` Dan Kegel
2003-03-01 19:18         ` Steven Cole
2003-03-01 21:20           ` Dan Kegel
2003-03-02  3:45             ` jw schultz
2003-03-02  2:08           ` Dan Kegel
2003-03-02  3:02             ` Dan Kegel
2003-03-02  3:54               ` Steven Cole
2003-03-02  8:04                 ` Dan Kegel
2003-03-02  4:16               ` Steven Cole
2003-03-02  8:21                 ` Dan Kegel
2003-03-02  8:40                   ` jw schultz
2003-03-02 11:21                 ` David Woodhouse
2003-03-02 13:49                   ` Steven Cole
2003-03-02 14:55                     ` David Woodhouse
2003-03-02 22:44                     ` Alan Cox
2003-03-02 22:59                       ` John Bradford
2003-03-03  2:29                       ` Dan Kegel
     [not found]                     ` <3E62C0FF.1090700@kegel.com>
     [not found]                       ` <1046661777.7527.518.camel@spc1.mesatop.com>
2003-03-03  5:36                         ` Dan Kegel
     [not found]                         ` <3E62E4C0.9070103@kegel.com>
     [not found]                           ` <1046668274.7527.533.camel@spc1.mesatop.com>
2003-03-03  5:48                             ` Dan Kegel
2003-03-02 15:35                   ` Dan Kegel
2003-03-02  8:09               ` Matthias Schniedermeyer
2003-03-02  8:13                 ` Matthias Schniedermeyer
2003-03-02  3:29             ` Steven Cole
2003-03-01 19:30         ` Matthias Schniedermeyer
2003-03-01 20:33           ` Matthias Schniedermeyer
2003-03-01 21:25           ` Dan Kegel
2003-03-01 21:25             ` Matthias Schniedermeyer
2003-03-02  9:15               ` John Bradford
2003-03-02  9:31                 ` Matthias Schniedermeyer
2003-03-02  3:16         ` Horst von Brand
  -- strict thread matches above, loose matches on Subject: below --
2003-03-01 15:57 shaheed
2003-03-01 16:35 ` Jörn Engel
2003-03-01 18:01   ` shaheed
2003-03-01 18:31     ` Jörn Engel
2003-03-05 18:10   ` Pavel Machek
     [not found] <20030301160017$56fc@gated-at.bofh.it>
2003-03-01 18:39 ` Pascal Schmidt
2003-03-02 18:56 Jared Daniel J. Smith
2003-03-02 17:22 ` Bernd Petrovitsch
2003-03-02 17:47   ` Werner Almesberger
2003-03-02 18:28     ` Bernd Petrovitsch
2003-03-02 18:46 ` Steven Cole
2003-03-02 22:32   ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E5DB755.20707@kegel.com \
    --to=dank@kegel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox