home *** CD-ROM | disk | FTP | other *** search
- From: jeff@quark.WV.TEK.COM (Jeff Beadles)
- Newsgroups: alt.sources
- Subject: Casefix - "Fix" all upper/lower case messages
- Message-ID: <6392@orca.wv.tek.com>
- Date: 10 Mar 90 23:35:52 GMT
-
- HAVE YOU BEEN SHOUTED AT ONCE TOO OFTEN IN ALL UPPER CASE?
-
- or, do you hate it when you get messages that are in all lower case?
-
- If so, then casefix might be the next best thing to user education.
-
- I tossed this together one morning, when I had received yet another file that
- was in all upper case. It works as a filter, so you can do things like
- (from rn)
-
- End of article 123 (of 123)--what next? [npq] | ~/.bin/casefix | more
-
-
- Have fun! I'll send it to comp.sources.misc in a few weeks. (Time to get any
- remaining kinks out.)
-
- -Jeff
-
- --
- Jeff Beadles jeff@orca.WV.TEK.COM uunet!tektronix!orca.wv!jeff
-
-
-
- #--------------------------------CUT HERE-------------------------------------
- #! /bin/sh
- #
- # This is a shell archive. Save this into a file, edit it
- # and delete all lines above this comment. Then give this
- # file to sh by executing the command "sh file". The files
- # will be extracted into the current directory owned by
- # you with default permissions.
- #
- # The files contained herein are:
- #
- # -rw-r--r-- 1 jeff 607 Mar 10 15:25 README
- # -rw-r--r-- 1 jeff 2226 Mar 10 15:28 casefix.c
- #
- echo 'x - README'
- if test -f README; then echo 'shar: not overwriting README'; else
- sed 's/^X//' << '________This_Is_The_END________' > README
- Xcasefix.c - Copyright 1990, Jeff Beadles. All rights reserved.
- X
- XPermission is granted to copy this at NO charge, as long as the copyright
- Xmessage remains intact.
- X
- XThis program will take all all upper/lower case text, and attempt to convert it
- Xto mixed case. It is not 100% accurate. It doesn't know about things
- Xlike proper nouns. (But what do you expect for free? :-)
- X
- XTo compile: cc -o casefix casefix.c (Simple enough.)
- X
- XTo use: casefix < ifile > ofile
- X
- XHave fun! Feel free to send constructive comments or patches.
- X
- X -Jeff
- X--
- XJeff Beadles jeff@orca.WV.TEK.COM (or) uunet!tektronix!orca.wv!jeff
- ________This_Is_The_END________
- if test `wc -c < README` -ne 607; then
- echo 'shar: README was damaged during transit (should have been 607 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'x - casefix.c'
- if test -f casefix.c; then echo 'shar: not overwriting casefix.c'; else
- sed 's/^X//' << '________This_Is_The_END________' > casefix.c
- X/*
- X * Submittor: Jeff Beadles jeff@orca.WV.TEK.COM
- X * Date: Sat Mar 10 15:12:46 PST 1990
- X * Name: casefix
- X * Version: 1.0
- X * Machine: Unix
- X * Synopsis: Fixes all upper/lower case text into mixed case.
- X * Category: utils
- X */
- X
- X/* casefix.c - Copyright 1990, Jeff Beadles. All rights reserved.
- X * Permission is granted to copy this at NO charge, as long as the copyright
- X * message remains intact.
- X *
- X * This is not 100% accurate. It doesn't know about things like proper nouns.
- X * (But what do you expect for free? :-)
- X *
- X * To compile: cc -o casefix casefix.c (Simple enough.)
- X *
- X * To use: casefix < ifile > ofile
- X *
- X * Have fun! Feel free to send constructive comments or patches to:
- X * jeff@quark.WV.TEK.COM or
- X * uunet!tektronix!orca.wv!jeff
- X */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X
- X/* ARGSUSED */
- Xmain(argc,argv)
- Xint argc;
- Xchar **argv;
- X
- X{
- X int ch; /* Tmp character holder */
- X int lastch; /* Last char displayed */
- X int nextch; /* Next character to be displayed (For I') */
- X int newsent; /* Start of sentence flag */
- X
- X newsent = 1; /* Start file with a new sentence */
- X nextch = lastch = -1; /* Nothing in them yet. */
- X
- X while(1) {
- X /* if readahead buffer is empty, then get another char */
- X if ( nextch == -1) {
- X if ( (ch = getc(stdin)) == EOF )
- X exit(0);
- X } else {
- X ch = nextch;
- X nextch = -1;
- X }
- X /* Default, is to make it lower case. */
- X ch = tolower(ch);
- X
- X /* Cap "(For example...)" */
- X if ( lastch == '(')
- X ch = toupper(ch);
- X
- X /* Cap "I will, I've */
- X if ( (isspace(lastch)) && (ch == 'i') ) {
- X if ( (nextch = getchar()) == EOF) {
- X putchar(ch);
- X exit(0);
- X }
- X /* Don't ungetc nextch, as it will be used next. */
- X if ((isspace(nextch)) || (nextch == '\'')) {
- X ch = toupper(ch);
- X }
- X }
- X
- X /* Cap 1st word of a new sentence. */
- X if ( (newsent) && isalpha(ch)) {
- X newsent = 0;
- X ch = toupper(ch);
- X }
- X
- X /* Sentences end with '.', '!', ':', '?', or ';'. */
- X if ( (ch == '.') || (ch == '!') ||
- X (ch == ':') || (ch == ';') || (ch == '?'))
- X newsent = 1;
- X
- X /* Finally, display the character */
- X putchar(ch);
- X lastch = ch;
- X }
- X}
- ________This_Is_The_END________
- if test `wc -c < casefix.c` -ne 2226; then
- echo 'shar: casefix.c was damaged during transit (should have been 2226 bytes)'
- fi
- fi ; : end of overwriting check
- exit 0
-