Xref: utzoo comp.unix.questions:15844 comp.lang.c:21088 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!oakhill!stevenw From: stevenw@oakhill.UUCP (Steven Weintraub) Newsgroups: comp.unix.questions,comp.lang.c Subject: Re: moving upper case names to lower case Summary: Not quite the answer. Message-ID: <2336@oakhill.UUCP> Date: 23 Aug 89 14:07:08 GMT References: <20672@adm.BRL.MIL> <9326@chinet.chi.il.us> Organization: Motorola Inc. Austin, Tx Lines: 37 In article <9326@chinet.chi.il.us>, john@chinet.chi.il.us (John Mundt) writes: > In article <20672@adm.BRL.MIL> Leisner.Henr@xerox.com (Marty) writes: > >I'm looking for a good, clean way to move files from upper case names > >to lower case names. > >i.e. FOO.C to foo.c > >I could always right a C program, but there gotta be a better way. > #include > #include > > main() > { > register int c; > while ((c = getchar()) != EOF) > putchar(tolower(c)); > } I should point out there is a risk in using tolower like this. Some machines define tolower as ((c)-'A'+'a') (like some sun systems). This works well if the character is an upper case letter but it will translate 'FOO.c' to 'fooN^C'. Some things are never so easy. I thus use (for portability): #define to_lower(c) (isupper(c):tolower(c)?(c)) (of course this to fails if you send in *p++, UHG!!) enough from this mooncalf - Steven ---------------------------------------------------------------------------- These opinions aren't necessarily Motorola's or Remora's - but I'd like to think we share some common views. ---------------------------------------------------------------------------- Steven R Weintraub | O Lord, ...!cs.utexas.edu!oakhill!stevenw | let me talk gently, Motorola Inc. Austin, Texas | for I might have to eat my (512) 891-3023 (office) (512) 453-6953 (home) | words tomorrow. ----------------------------------------------------------------------------