home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
lang
/
word301_.txt
< prev
next >
Wrap
Text File
|
1987-10-17
|
12KB
|
371 lines
17-Oct-87 13:32:58-MDT,12639;000000000000
Return-Path: <science@nems.ARPA>
Received: from nems.ARPA by SIMTEL20.ARPA with TCP; Sat, 17 Oct 87 13:32:35 MDT
Received: by nems.ARPA id AA24633; Sat, 17 Oct 87 15:32:49 edt
Message-Id: <8710171932.AA24633@nems.ARPA>
Date: 17 Oct 87 15:32 EDT
From: science@nems.ARPA (Mark Zimmermann)
Subject: tnx for files! ... fixtext, etc.
To: rthum@simtel20.ARPA
Thanks for the files that are coming in! Don't worry about the missing
issues of delphi & usenet ... perhaps they were never sent out?
Anyway, appended below are fixtextword.hqx and fixtext.c files, for
fixing big text files against Word 3.01 bug (when a <cr> falls on
a 64kB boundary).... sent them to <Info-Mac> yesterday or so, so they
should be coming into their archives soon too.
Best, ^z
------
/* fixtextWord.c -- by Mark^Zimmermann, 19871014-16....
*
* This little effort cleans up a text file so that MicroSoft
* Word 3.01 doesn't barf when it encounters a <cr> at a 64 kB
* boundary ... it simply changes all such offensive <cr>'s to
* <space> characters, in place ... perhaps the easiest way out.
* The bug in Word 3.01 was discovered and documented by Peter Gergely
* (GERGELY(at)DREA-XX.ARPA) and Gavin Hemphill....
*
* Written in Lightspeed C ... my first real "Mac-ish" program,
* (that is, not UNIX-like) based on LSC's MiniEdit example, lobotomized.
* Please send improvements and suggestions to me:
* science(at)NEMS.ARPA;
* [75066,2044] on CompuServe;
* Mark^Zimmermann, 9511 Gwyndale Dr., Silver Spring, MD 20910, USA;
* telephone 301-565-2166.
*
* Thank you! ^z
*/
/* I don't know if all of these #includes are necessary.... */
#include <QuickDraw.h>
#include <MacTypes.h>
#include <FontMgr.h>
#include <WindowMgr.h>
#include <MenuMgr.h>
#include <TextEdit.h>
#include <DialogMgr.h>
#include <EventMgr.h>
#include <DeskMgr.h>
#include <FileMgr.h>
#include <ToolboxUtil.h>
#include <ControlMgr.h>
#include "StdFilePkg.h"
/* prototypes for my functions ... I do love prototypes! */
void main (void);
void ChangeCRtoSP (void);
int getCharacter (long pos);
void setCharacter (long pos, int c);
void WrapAround (void);
int GetFileToFix (Str255 *fn, int *vRef);
void pStrCopy (char *p1, char *p2);
void GiveMsg (void);
void giveUp (void);
int refNum;
WindowPtr wptr;
/* main routine to initialize everything under the sun (is all this
* really necessary?) and then get the name of the file to fix ... if
* it opens ok, fix it and then we're done....
*/
void main()
{
Str255 fn, ermsg;
int vRef;
InitGraf (&thePort);
InitFonts ();
FlushEvents (everyEvent, 0);
InitWindows ();
InitMenus ();
TEInit ();
InitDialogs (0L);
InitCursor ();
MaxApplZone ();
GiveMsg ();
if (GetFileToFix (&fn, &vRef))
if (FSOpen (&fn, vRef, &refNum) == noErr)
{
ChangeCRtoSP ();
FSClose (refNum);
}
else
giveUp ();
}
/* routine to change a <cr> at a 64kB boundary into a space, and give
* a little user feedback while doing so....
*/
void ChangeCRtoSP ()
{
long fsize, i;
if (GetEOF (refNum, &fsize) != noErr)
giveUp ();
ShowWindow (wptr);
MoveTo (4, 15);
for (i = 65535; i < fsize; i += 65536)
if (getCharacter (i) == '\r')
{
setCharacter (i, ' ');
DrawString ("\p*");
WrapAround ();
}
else
{
DrawString ("\p.");
WrapAround ();
}
MoveTo (4, 135);
FlushEvents (everyEvent, 0);
DrawString ("\pClick mouse button to exit....");
while (! Button())
;
}
/* routine to get the character at position 'pos' in our file
*/
int getCharacter (pos)
long pos;
{
long count = 1;
int c;
if (SetFPos (refNum, fsFromStart, pos) != noErr)
giveUp ();
if (FSRead (refNum, &count, &c) != noErr)
giveUp ();
return (c >> 8);
}
/* routine to set the character at position 'pos' to be whatever we
* want (in this case, a space)....
*/
void setCharacter (pos, c)
long pos;
int c;
{
long count = 1;
c <<= 8;
if (SetFPos (refNum, fsFromStart, pos) != noErr)
giveUp ();
if (FSWrite (refNum, &count, &c) != noErr)
giveUp ();
}
/* routine to wrap the line of dots and stars around when it gets too
* long for the window ... wrap-around occurs at 6 MB or so per line,
* and I've never seen vertical wrap-around, though presumably it will
* happen around 60 MB or so....
*/
void WrapAround ()
{
Point pt;
GetPen (&pt);
if (pt.h >= 400)
MoveTo (4, pt.v + 15);
if (pt.v >= 135)
MoveTo (4, 15);
}
/* following variables and routine do the standard files dialog
* to get the name of the file to fix ... cribbed from the MiniEdit
* example that comes with LSC....
*/
static Point SFGwhere = { 90, 82 };
static SFReply reply;
int GetFileToFix (fn, vRef)
Str255 *fn;
int *vRef;
{
SFTypeList myTypes;
myTypes[0]='TEXT';
SFGetFile( SFGwhere, "\p", 0L, 1, myTypes, 0L, &reply);
if (reply.good)
{
pStrCopy( (char *)reply.fName, (char *)fn);
*vRef = reply.vRefNum;
return(1);
}
else return(0);
}
/* routine to copy a pascal string from one place to another.... used in
* above Standard Files routine....
*/
void pStrCopy( p1, p2 )
register char *p1, *p2;
{
register int len;
len = *p2++ = *p1++;
while (--len>=0)
*p2++=*p1++;
}
/* routine to give a message to the user upon start-up of the program....
*/
void GiveMsg()
{
Rect r;
SetRect (&r, 50, 60, 462, 200);
SetPort ((wptr = NewWindow (0L, &r, "\p", 1, 1, -1L, 0, 0L)));
TextFont (0);
MoveTo (4, 15);
DrawString ("\pThis program changes <cr>'s at 64kB boundaries to <space>'s");
MoveTo (4, 30);
DrawString ("\pto avoid a bug in Microsoft Word 3.01 discovered by");
MoveTo (4, 45);
DrawString ("\pPeter Gergely & Gavin Hemphill. Each character changed");
MoveTo (4, 60);
DrawString ("\pwill cause a '*' to be printed.");
MoveTo (4, 90);
DrawString ("\pThis program is by Mark^Zimmermann, science(at)NEMS.ARPA,");
MoveTo (4, 105);
DrawString ("\p[75066,2044] CompuServe, and was written in LightSpeed C.");
MoveTo (4, 120);
DrawString ("\pWhen asked, pick a text file to be fixed, or choose 'Cancel'");
MoveTo (4, 135);
DrawString ("\pto quit. Click the mouse button to continue....");
while (! Button())
;
FlushEvents (everyEvent, 0);
HideWindow (wptr);
}
/* routine to give up with a beep if an error occurs during opening the
* file or fixing it....
*/
void giveUp ()
{
SysBeep (10);
ExitToShell ();
}
(This file must be converted with BinHex 4.0)
:#fCTH(4PH(4AEh*N!%&38%a$9%aD)!#3"a$qK)X!N!3"!*!$%&!!!!p3!*!$V[r
m1!*K!2VbCbj+XN!fCb*$kJ"QG!G+%@F1d[`!$&(+#fCTH(4PH(4AEh*N!J#3!d&
38%`rN!3J!*!*39"36$q3"#!!N"HGQmN'!*!'%2jK!2pU8LX!B4!V!''3!#J!,'`
!!4T5!'B)%#J!(B%V!'!`'53C9%NR@3"NiNPNeNTTrrTRd%K"B3$lZNK"B-C1G5m
b)$BJAfIf)8N!%K&M!#`a3!!Z3qJ!(4,M)S&(mL"1YdPR"NTVrrjQe(!#Y`PR"NS
VrrpQb&0!C[+A85@3!#!fB!#3!`(8!5S",Kj$E'PMDb"YEh9cC5"LGA4dEfiJG'm
JCAKTG#k3"!#3"6Y8D'Pc)("bEfGbB@dJBfKKEQGPFb!mBh)q*h-JBA3J0M4V3L"
LEh9ZC'&bD@9c)(4[)$acF'&MC6iRFc0dEb"KGQpTC#"K)'*eCb"TEL"0D@0bEh0
[CR3J9fpbC#!c,M!a)'4TFf0[GQ9bC@3JBRNh8'9dCA)J4f9bCf9XH5!Q)%GKGQP
Z)%KPEA"SD@aX,L!J4@&MD#"MD'&bB@0dCA)JBfKKEQGPC"phD@aX)'0KGA0P)'%
J*bSR)(4[)'*P)("bD@jdC@3Z194SDA-JF(*[Ch*KE5"TFb"LH5"0BA*VAPTTE@e
PFQeKEQiX)(0MD@9ZBf8SBA3T6N908bj"8P"",$PE0c8`0MBX-M!d0&dJ3fpYF(9
6CA*fC5`JB@jN)(GKFb"hFQPdG'9Z)'PZ)%aTCfKd8h"PC@3J3bim9fKPEL"KFfY
PC#`JF'PMDb"K)(4PH(3JCQPXC5"dEb"LC5"QDAKPC#`JEh)JBfK[Eh0P)#G$B@j
MC@`R!$"dE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