Utility to convert uppercase filenames

Jeff Beadles jeff at onion.pdx.com
Wed Dec 12 17:14:49 AEST 1990


In article <7529 at castle.ed.ac.uk> aipdc at castle.ed.ac.uk (Paul Crowley) writes:
>I'd like to know if there's an "intelligent" casing program out there
>that I could feed "BIFF" posts through.  Something that would capitalise
>after full stops, and recognise some proper nouns, for example. 
>Mixed-case is so much easier to read.

***
 Note:  Alt.sources is for source code postings only.  Please PLEASE use
	alt.sources.d for discussions.  Thank you.
***

Now, on to the source code.  I've posted this before, but since it's so short
I'll post it again.  It gets "I" right, but doesn't know about other proper
nouns.  It's free, so if you don't like it, "rm" it. :-)


-------Start of readme (from the casefix.sh archive)------
casefix.c - Copyright 1990, Jeff Beadles.  All rights reserved.

Permission is granted to copy this at NO charge, as long as the copyright
message remains intact.

This program will take all all upper/lower case text, and attempt to convert it
to mixed case.  It is not 100% accurate.  It doesn't know about things
like proper nouns.  (But what do you expect for free? :-)

To compile:  cc -o casefix casefix.c  (Simple enough.)

To use:  casefix < ifile > ofile

Have fun!  Feel free to send constructive comments or patches.

	-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          605 Dec 11 22:10 README
# -rw-r--r--  1 jeff         2213 Dec 11 22:10 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 at onion.pdx.com	(or) ...!uunet!onion.pdx.com!jeff
________This_Is_The_END________
if test `wc -c < README` -ne 605; then
	echo 'shar: README was damaged during transit (should have been 605 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 at onion.pdx.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 at onion.pdx.com
X *	uunet!onion.pdx.com!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 2213; then
	echo 'shar: casefix.c was damaged during transit (should have been 2213 bytes)'
fi
fi		; : end of overwriting check
exit 0



More information about the Alt.sources mailing list