From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/7714 Path: main.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.emacs.gnus.general Subject: C stack overflow in emacs (19.33) regexp code Date: Sat, 24 Aug 1996 00:36:51 -0400 Message-ID: <9608240436.AA11619@cujo.cygnus.com> NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035147990 8320 80.91.224.250 (20 Oct 2002 21:06:30 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 21:06:30 +0000 (UTC) Cc: ding@ifi.uio.no Return-Path: ding-request@ifi.uio.no Original-Received: from ifi.uio.no (ifi.uio.no [129.240.64.2]) by deanna.miranova.com (8.7.5/8.6.9) with SMTP id VAA12879 for ; Fri, 23 Aug 1996 21:53:36 -0700 Original-Received: from cygnus.com (cygnus.com [140.174.1.1]) by ifi.uio.no with ESMTP (8.6.11/ifi2.4) id for ; Sat, 24 Aug 1996 06:37:04 +0200 Original-Received: from tweedledumb.cygnus.com (tweedledumb.cygnus.com [192.80.44.1]) by cygnus.com (8.6.12/8.6.9) with SMTP id VAA24372; Fri, 23 Aug 1996 21:36:58 -0700 Original-Received: from cujo.cygnus.com by tweedledumb.cygnus.com (4.1/4.7) id AA01258; Sat, 24 Aug 96 00:36:56 EDT Original-Received: by cujo.cygnus.com; (5.65v3.2/1.1.8.2/20Sep95-0235PM) id AA11619; Sat, 24 Aug 1996 00:36:51 -0400 Original-To: bug-gnu-emacs@prep.ai.mit.edu Xref: main.gmane.org gmane.emacs.gnus.general:7714 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:7714 (Sorry if this has been reported. This bug is making it difficult for me to read news and mail, so I haven't checked to see.) I've seen this problem in both i386-netbsd and alpha-osf3.2 configurations. I'm using emacs 19.33. I don't have the original spam message that caused the problem for me on the x86 (four or five times, as multiple copies came in), but the big elisp form below, based on another message I just received, crashes emacs on my alpha. (If it doesn't crash it for you, try expanding the "to" field by a factor of 5 or 10, and/or reducing your stack size limit.) Don't evaluate it if you haven't saved your buffers first... In Red Gnus 0.11, header lines in an incoming mail message are joined at the continuation breaks, and various regular expressions applied to the result. You get *really* long lines when some obnoxious brain-dead *@%$!# sends mail with a 150-line "to" header. My guess is that the space used by the regexp code is related to the search buffer size, or the contents. (I don't know why. I would've expected it to be derived entirely from size of the DFA needed to recognize the input pattern. But it's been years since my algorithms course and I don't remember the regexp stuff well.) And it's on the stack. On both of the systems I've been using, this crashes emacs. I'm using default stack size limits on each system. Emacs does fine with smaller buffers and the same set of patterns. I took a look at regex.c. I don't grok the regexp aspect yet, and haven't tried much, but it appears to me that DOUBLE_FAIL_STACK could be more clever about trying to reuse the already-allocated stack space. It would only save a factor of 2 or 1.5 or something like that, and only on the systems where that sort of thing can work. I don't think it's an adequate solution for this problem, just a space optimization. Some approaches I can think of: * find a way to improve the space requirements of the RE algorithm (offers greatest potential reward, but probably hardest) * use malloc and realloc always, by defining REGEX_MALLOC (maybe it would fail more cleanly?) * change gnus header scanning to avoid this bug (but I'm not sure how; maybe searching for field names and values separately would help? I'm skeptical, but can't rule it out since I don't know precisely why so much memory is needed) * do "unlimit stacksize" within emacs (not a big help if space requirements are linear or worse) * write a "realloca" to use less stack space (ditto) * kill people who send spam, or at least hurt them badly (gratifying, perhaps, but not legal, and would only happen after the mail has been sent anyways) Ken (progn (setq crap "Received: from cygnus.com by tweedledumb.cygnus.com (4.1/4.7) id AA18620; Fri, 23 Aug 96 13:28:19 EDT Received: from gnu-life.ai.mit.edu (gnu-life.ai.mit.edu [128.52.32.60]) by cygnus.com (8.6.12/8.6.9) with ESMTP id KAA07004; Fri, 23 Aug 1996 10:28:11 -0700 Received: from mailh1a.cyberway.com.sg by gnu-life.ai.mit.edu (8.6.12/8.6.12GNU) with ESMTP id NAA22837; Fri, 23 Aug 1996 13:22:02 -0400 Received: from LOCALNAME (d4032.ppp4.cyberway.com.sg [203.116.4.32]) by mailh1a.cyberway.com.sg (8.7.3/8.7.3) with SMTP id WAA18025; Fri, 23 Aug 1996 22:13:57 +0800 (SST) Message-Id: <199608231413.WAA18025@mailh1a.cyberway.com.sg> X-Sender: kaizen93@cyberway.com.sg (Unverified) X-Mailer: Windows Eudora Pro Version 2.1.2 Mime-Version: 1.0 Content-Type: text/plain; charset=\"us-ascii\" Date: Fri, 23 Aug 1996 22:13:33 -0500 To: killies@mejac.palo-alto.ca.us, cdrom-l@uccvma.ucop.edu, clear-l@vm.ucs.ualberta.ca, magic-l@american.edu, cfids-l@american.edu, cfs-l@list.nih.gov, fibrom-l@vmd.cso.uiuc.edu, art@ipc.uni-tuebingen.de, blues-traveler@cs.umd.edu, jewish-music@israel.nysernet.org, paranet@psuvm.psu.edu, altufo-l@psuvm.psu.edu, lrh-l@cornell.edu, undercover@snowhite.cis.uoguelph.ca, mslist-l@technion.technion.ac.il, alt-sys-intergraph@ingr.ingr.com, gateway2000-request@sei.cmu.edu, winsock@microdyne.com, neder-l@hearn.nic.surfnet.nl, 3com-l@nusvm.nus.sg, 9370-l@hearn.nic.surfnet.nl, ada-law@vm1.nodak.edu, advanc-l@idbsu.idbsu.edu, advise-l@uga.cc.uga.edu, aect-l@wvnvm.wvnet.edu, aera@asuvm.inre.asu.edu, aix-l@pucc.princeton.edu, allmusic@auvm.american.edu, appc-l@auvm.american.edu, apple2-l@brownvm.brown.edu, applicat@uga.cc.uga.edu, arie-l@idbsu.idbsu.edu, ashe-l@american.edu, asis-l@vmd.cso.uiuc.edu, asm370@uga.cc.uga.edu, aware@cc1.kuleuven.ac.be, autism@sjuvm.stjohns.edu, autocat@ubvm.cc.buffalo.edu, axslib-l@bitnic.cren.net, banyan-l@vm1.cc.uakron.edu, basque-l@cunyvm.cuny.edu, berita-l@vmd.cso.uiuc.edu, berita-d@vmd.cso.uiuc.edu, big-lan@suvm.acs.syr.edu, billing@hearn.nic.surfnet.nl, biosph-l@ubvm.cc.buffalo.edu, bitnews@uga.cc.uga.edu, blindnws@vm1.nodak.edu, blues-l@brownvm.brown.edu, bosnews@doc.ic.ac.uk, buslib-l@idbsu.idbsu.edu, c+health@Iubvm.cc.buffalo.edu, c18-l@psuvm.psu.edu, c370-l@cmuvm.csv.cmich.edu, calc-ti@lists.ppp.ti.com, candle-l@ua1vm.ua.edu, catala@puigmal.cesca.es, catholic@auvm.american.edu, cdromlan@idbsu.idbsu.edu, cfs-news@list.nih.gov, christia@asuvm.inre.asu.edu, cics-l@uga.cc.uga.edu, cinema-l@auvm.american.edu, circplus@idbsu.idbsu.edu, cmspip-l@vm.marist.edu, coco@pucc.princeton.edu, csg-l@vmd.cso.uiuc.edu, cumrec-l@vm1.nodak.edu, cw-email@tecmtyvm.mty.itesm.mx, cwis-l@msu.edu, cyber-l@uga.cc.uga.edu, dasig@suvm.acs.syr.edu, db2-l@auvm.american.edu, deaf-l@siucvmb.siu.edu, decnews@ubvm.cc.buffalo.edu, dectei-l@ubvm.cc.buffalo.edu, devel-l@auvm.american.edu, devmedia@uoguelph.ca, disarm-l@uacsc2.albany.edu, domain-l@uga.cc.uga.edu, down-syn@vm1.nodak.edu, e-europe@pucc.princeton.edu, earntech@bitnic.cren.net, edi-l@uccvma.ucop.edu, edpolyan@asuvm.inre.asu.edu, edtech@msu.edu, edusig-l@ubvm.cc.buffalo.edu, endnote@ucsbvm.ucsb.edu, envbeh-l@vm.poly.edu, ethics-l@uga.cc.uga.edu, euearn-l@ubvm.cc.buffalo.edu, film-l@itesmvf1.rzs.itesm.mx, fnord-l@ubvm.cc.buffalo.edu, frac-l@gitvm1.gatech.edu, free-l@indycms.iupui.edu, freemasonry@indy.cms, games-l@brownvm.brown.edu, gaynet@queernet.org, gddm-l@vm.poly.edu, geodesic@ubvm.cc.buffalo.edu, geograph@searn.sunet.su, gguide@uga.cc.uga.edu, gophern@ubvm.cc.buffalo.edu, govdoc-l@psuvm.psu.edu, graph-ti@lists.ppp.ti.com, gutnberg@vmd.cso.uiuc.edu, hdesk-l@wvnvm.wvnet.edu, hellas@auvm.american.edu, help-net@vm.temple.edu, hindu-d@arizvm1.ccit.arizona.edu, history@psuvm.psu.edu, humage-l@asuvm.inre.asu.edu, hungary@gwuvm.gwu.edu, hytel-l@kentvm.kent.edu, i-amiga@rutvm1.rutgers.edu, ibm-hesc@cc.pdx.edu, ibm-main@ricevm1.rice.edu, ibm-nets@bitnic.cren.net, ibm7171@vmd.cso.uiuc.edu, ibmtcp-l@pucc.princeton.edu, idms-l@uga.cc.uga.edu, imagelib@arizvm1.ccit.arizona.edu, info-gcg@vm.utcc.utoronto.ca, ingrafx@ubvm.cc.buffalo.edu, innopac@maine.maine.edu, ioob-l@uga.cc.uga.edu, ipct-l@guvm.ccf.georgetown.edu, isn@ritvm.isc.rit.edu, japan@pucc.princeton.edu, jes2-l@vtvm1.cc.vt.edu, jnet-l@uga.cc.uga.edu, l-hcap@vm1.nodak.edu, l-vmctr@vm1.cc.uakron.edu, lawsch-l@auvm.american.edu, liaison@uga.cc.uga.edu, libref-l@kentvm.kent.edu, libres@kentvm.kent.edu, license@uga.cc.uga.edu, linkfail@uga.cc.uga.edu, lis-l@vmd.cso.uiuc.edu, literary@ucf1vm.cc.ucf.edu, lsoft-announce@searn.sunet.se, lstsrv-l@uga.cc.uga.edu, mail-l@uga.cc.uga.edu, mailbook@ricevm1.rice.edu, mba-l@vm.marist.edu, mbu-l@unicorn.acs.ttu.edu, mdphd-l@ubvm.cc.buffalo.edu, medforum@arizvm1.ccit.arizona.edu, medlib-l@ubvm.cc.buffalo.edu, mednews@asuvm.inre.asu.edu, mideur-l@ubvm.cc.buffalo.edu, mla-l@iubvm.ucs.indiana.edu, museum-l@unmvma.unm.edu, muslims@psuvm.psu.edu, netnws-l@vm1.nodak.edu, nettrain@ubvm.cc.buffalo.edu, new-list@vm1.nodak.edu, next-l@brownvm.brown.edu, nodmgt-l@uga.cc.uga.edu, notabene@taunivm.tau.ac.il, notis-l@uicvm.cc.uic.edu, novell@suvm.acs.syr.edu, nppa-l@cmuvm.csv.cmich.edu, opers-l@vm1.cc.akron.edu, os2-l@hearn.nic.surfnet.nl, pacs-l@uhupvm1.uh.edu, page-l@ucf1vm.cc.ucf.edu, pagemakr@indycms.iupui.edu, pakistan@psuvm.psu.edu, physhare@psuvm.psu.edu, pmail@ua1vm.ua.edu, pmdf-l@irlearn.ucd.ie, pns-l@psuvm.psu.edu, politics@villvm.vill.edu, por@unc.edu, postcard@idbsu.idbsu.edu, power-l@vm1.nodak.edu, powerh-l@unbvm1.csd.unb.ca, psycgrad@acadvm1.uottawa.ca, quaker-p@vmd.cso.uiuc.edu, quality@pucc.princeton.edu, qualrs-l@uga.cc.uga.edu, relusr-l@vtvm1.cc.vt.edu, rra-l@kentvm.kent.edu, rscs-l@pucc.princeton.edu, rscsmods@uga.cc.uga.edu, screen-l@ua1vm.ua.edu, script-l@uga.cc.uga.edu, scuba-l@brownvm.brown.edu, seasia-l@msu.edu, seds-l@tamvm1.tamu.edu, sfs-l@searn.sunet.se, sganet@vtvm1.cc.vt.edu, simula@uga.cc.uga.edu, skeptic@jhuvm.hcf.jhu.edu, slart-l@cunyvm.cuny.edu, slovak-l@ubvm.cc.buffalo.edu, snamgt-l@umrvmb.umr.edu, snurse-l@ubvm.cc.buffalo.edu, sos-data@gibbs.oit.unc.edu, spires-l@uga.cc.uga.edu, sportpsy@vm.temple.edu, sqlinfo@uicvm.cc.uic.edu, sthcult@unc.edu, superguy@ucf1vm.cc.ucf.edu, tbi-sprt@sjuvm.stjohns.edu, tech-l@uga.cc.uga.edu, techwr-l@vm1.ucc.okstate.edu, tecmat-l@ubvm.cc.buffalo.edu, tesl-l@cunyvm.cuny.edu, test@psuvm.psu.edu, tex-l@ubvm.cc.buffalo.edu, tn3270-l@rutvm1.rutgers.edu, toolb-l@uafsysb.uark.edu, trans-l@uga.cc.uga.edu, trnsplnt@wuvmd.wustl.edu, travel-l@vm.ege.edu.tr, tso-rexx@ucf1vm.cc.ucf.edu, ucp-l@ubvm.cc.buffalo.edu, ug-l@uga.cc.uga.edu, uigis-l@ubvm.cc.buffalo.edu, urep-l@psuvm.psu.edu, usrdir-l@uga.cc.uga.edu, uus-l@ubvm.cc.buffalo.edu, valert-l@lehigh.edu, vfort-l@jhuvm.hcf.jhu.edu, vm-util@utarlvm1.uta.edu, vmesa-l@uafsysb.uark.edu, vmslsv-l@ubvm.cc.buffalo.edu, vmxa-l@uga.cc.uga.edu, vnews-l@ubvm.cc.buffalo.edu, vocnet@cmsa.berkeley.edu, vpiej-l@vtvm1.cc.vt.edu, vse-l@lehigh.edu, wac-l@vmd.cso.uiuc.edu, win3-l@uicvm.cc.uic.edu, words-l@uga.cc.uga.edu, wpcorp-l@ubvm.cc.buffalo.edu, wpwin-l@ubvm.cc.buffalo.edu, www-vm@sjuvm.stjohns.edu, wx-talk@vmd.cso.uiuc.edu, x400-l@uga.cc.uga.edu, xedit-l@uga.cc.uga.edu, xerox-l@tamvm1.tamu.edu, xmailer@uga.cc.uga.edu, xtropy-l@ubvm.cc.buffalo.edu, word-mac@alsvid.une.edu.au, word-pc@ufobi1.uni-forst.gwdg.de, rc_world@indycms.iupui.edu, pcorps-l@cmuvm.csv.cmich.edu, insoft-l@cis.vutbr.cz, africana-l@warthog.cc.wm.edu, fuzzy-mail@vexpert.dbai.tuwien.ac.at, autocad@jhuvm.hcf.jhu.edu, compil-l@auvm.american.edu, pccts-users@ahpcrc.umn.edu, info-ingres@math.ams.com, modems-l@vm.its.rpi.edu, cisco@spot.colorado.edu, telecom@eecs.nwu.edu, unix-emacs@bbn.com, xemacs@cs.uiuc.edu, info-gnuplot@dartmouth.edu, alias-l@uga.cc.uga.edu, lnotes-l@nda.com, home-l@coco.ini.ku.dk, gis-l@ubvm.cc.buffalo.edu, kiosks-l@lanl.gov, info-ada@vm1.nodak.edu, apl-l@unb.ca, info-c@arl.army.mil, help-g++@prep.ai.mit.edu, umforth%weizmann.BITNET@mitvma.mit.edu, info-m2%ucf1vm.BITNET@mitvma.mit.edu, mumps-l@uga.cc.uga.edu, info-pascal@arl.army.mil, info-prograph@grove.iup.edu, prolog@score.stanford.edu, rexxlist@uga.cc.uga.edu, info-cls@vm.gmd.de, mh-users@ics.uci.edu, pine-info@cac.washington.edu, music-research@prg.oxford.ac.uknewprod-request@chinacat.unicom.com, acm-l@kentvm.kent.edu, eff-news@eff.org, eff-talk@eff.org, coherent@vma.cc.nd.edu, cpm-l@vm.its.rpi.edu, linux-admin@SENATOR-BEDFELLOW.MIT.EDU, linux-announce@SENATOR-BEDFELLOW.MIT.EDU, linux-devel@SENATOR-BEDFELLOW.MIT.EDU, linux-help@SENATOR-BEDFELLOW.MIT.EDU, linux-misc@SENATOR-BEDFELLOW.MIT.EDU, info-minix@udel.edu, 4dos@vma.cc.nd.edu, info-vax@sri.com, litprog@shsu.edu, kerberos@athena.mit.edu, tcp-ip@nic.ddn.mil, pcip@list.nih.gov, res-japan-group@cs.arizona.edu, risks@csl.sri.com, comsoc@auvm.american.edu, tk0jut2@mvs.cso.niu.edu, comp-privacy@pica.army.mil, nextstep@vma.cc.nd.edu, sas-l@vtvm1.cc.vt.edu, spssx-l@uga.cc.uga.edu, wavefr-l@psuvm.psu.edu, unix-sources@arl.army.mil, unix-sources@pa.dec.com, zforum@comlab.ox.ac.uk, csys-ami%mainecs@cunyvm.cuny.edu, ami-hard%mainecs@cunyvm.cuny.edu, ami-tech%mainecs@cunyvm.cuny.edu, apollo@umix.cc.umich.edu, info-apple@apple.com, info-atari8-request@pine.cse.nau.edu, info-atari16-request@pine.cse.nau.edu, hp3000-l@utcvm.utc.edu, micro-l@vm.its.rpi.edu, next-advocacy-d@antigone.com, next-announce-d@antigone.com, next-bugs-d@antigone.com, next-hardware-d@antigone.com, next-marketplace-d@antigone.com, next-misc-d@antigone.com, next-programmer-d@antigone.com, next-software-d@antigone.com, next-sysadmin-d@antigone.com, info-tahoe@csd1.milw.wisc.edu, info-1100@archive.cis.ohio-state.edu, info-terms@mc.lcs.mit.edu, dtp-l@antigone.com, info-tex@shsu.edu, solaris@vma.cc.nd.edu, virus-l@lehigh.edu, interviews@interviews.stanford.edu, xpert@x.org, xannounce@x.org, info-gnu@prep.ai.mit.edu, bug-bash@prep.ai.mit.edu, info-gnu-chess@prep.ai.mit.edu, bug-gnu-chess@prep.ai.mit.edu, info-gnu-emacs@prep.ai.mit.edu, bug-gnu-emacs@prep.ai.mit.edu, info-gnews@ics.uci.edu, info-gnus-english@cis.ohio-state.edu, help-gnu-emacs@prep.ai.mit.edu, gnu-emacs-sources@prep.ai.mit.edu, bug-vm@uunet.uu.net, info-vm@uunet.uu.net, vms-gnu-emacs@prep.ai.mit.edu, info-g++@prep.ai.mit.edu, bug-g++@prep.ai.mit.edu, help-g++@prep.ai.mit.edu, bug-lib-g++@prep.ai.mit.edu, info-gcc@prep.ai.mit.edu, bug-gcc@prep.ai.mit.edu, help-gcc@prep.ai.mit.edu, bug-gdb@prep.ai.mit.edu, bug-ghostscript@prep.ai.mit.edu, bug-groff@prep.ai.mit.edu, gnu-misc-discuss@cis.ohio-state.edu, bug-gnu-smalltalk@prep.ai.mit.edu, bug-gnu-utils@prep.ai.mit.edu, emerg-l@vm.marist.edu, rferl-l@ubvm.cc.buffalo.edu, fedtax-l@shsu.edu, transit@gitvm1.gatech.edu, anu-news@vm1.nodak.edu, anime-l@vtvm1.cc.vt.edu, bonsai@cms.cc.wayne.edu, rec-arts-cinema-d@antigone.com, ballroom@mitvma.mit.edu, drwho-l@east-london.ac.uk, drumcorps-digest@cisco.com, sf-lovers@rutgers.edu, trek-review-l@cornell.edu, info-high-audio@introl.com, jewelry@mishima.mn.org, recipes@vistachrome.com, dipl-l@nda.com, hunting@tamvm1.tamu.edu, juggling@moocow.cogsci.indiana.edu, earlym-l@helios.edvz.univie.ac.at, love-hounds@uunet.uu.net, dead-flames@virginia.edu, synth-l@auvm.auvm.edu, phish@phish.net, sca@mc.lcs.mit.edu, info-hams@ucsd.edu, packet-radio@ucsd.edu, ham-policy@ucsd.edu, journal@airwaves.chi.il.us, radio-info@ucsd.edu, swl-l@cuvmb.cc.columbia.edu, nordic-ski@graphics.cornell.edu, ultimate-list@doe.carleton.ca, golf-l@ubvm.cc.buffalo.edu, videotech@wsmr-simtel20.army.mil, dbssat@vm1.nodak.edu, miscsat@vm1.nodak.edu, woodwork%ipfwvm@indycms.iupui.edu, airliners@chicago.com, scifaq-l@yalevm.ycc.yale.edu, fitsbits@nrao.edu, ecolog-l@umdd.umd.edu, ethology@searn.sunet.se, evolution@pogo.cqs.washington.edu, herp-l@xtal200.harvard.edu, pol-econ@shsu.edu, hydrogen@uriacc.uri.edu, nihongo@mitvma.mit.edu, aids@rutvm1.rutgers.edu, hspnet-l%albnydh2@cunyvm.cuny.edu, physics@unix.sri.com, fusion@zorch.sf-bay.org, psyc@pucc.princeton.edu, space@isu.isunet.edu, stat-l@vm1.mcgill.ca, edstat-l@jse.stat.ncsu.edu, chile-l@tamvm1.tamu.edu, scj@nysernet.org, nepal@mp.cs.niu.edu, scs-l@indycms.iupui.edu, vietnet@usc.edu, feminism-digest@netcom.com, gencmp-l@gitvm1.gatech.edu, gen-fr-l@gitvm1.gatech.edu, jewgen@gitvm1.gatech.edu, genmtd-l@gitvm1.gatech.edu, genmsc-l@gitvm1.gatech.edu, gennam-l@gitvm1.gatech.edu, hist-sci@cshl.org, usnonprofit-l@rain.org, arms-l@buacca.bu.edu, bahai-faith@oneworld.new-era.com, bible-study@spss.com, tps-l@indycms.iupui.edu, vmsgopher-l@trln.lib.unc.edu, macro32@wkuvx1.wku.edu, mx-list@wkuvx1.wku.edu, lanworks@miamiu.acs.muohio.edu, decmcc-l@auvm.american.edu, cmu-openvms-ip@drycas.club.cc.cmu.edu, info-multinet@tgv.com, wintcp-l@ubvm.cc.buffalo.edu, info-tpu@shsu.edu, vmsnet@drycas.club.cc.cmu.edu From: Jeffrey Tay Swee Kim Subject: Free Software Blah blah blah, same old spam crap every moron posts who thinks the Internet is his personal advertising service.") (set-buffer (get-buffer-create "spam-crap")) (erase-buffer) (insert crap) (goto-char (point-min)) (while (re-search-forward "\n[ \t]+" nil t) (replace-match " " nil nil)) (goto-char (point-max)) ; Say good night, Gracie. (re-search-backward "^\\(to\\|cc\\|apparently-to\\):.*\\<\\(.*rdist.*@.*usc.edu\\)\\>" nil t nil) )