public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Control M ????
       [not found] <616BE6A276E3714788D2AC35C40CD18D3F2CB8@whale.softwire.co.uk>
@ 2002-02-12  5:14 ` Rupert Wood
  0 siblings, 0 replies; 4+ messages in thread
From: Rupert Wood @ 2002-02-12  5:14 UTC (permalink / raw)
  To: kabir.patel; +Cc: gcc-help

Kabir Patel wrote:

> Some time back I mentioned a problem I had with the ^M character
> (see below). It so happens that I need to be able to replace every
> ^M in my resultant file with a " " charachter. GNU isn't happy with
> ^M. Is there a way to define ^M in another way?

Yes, this is exactly the problem you had before.

^M is ASCII 13, representing carriage return (CR); hence you could
replace the single character constant '^M' with any of the following:

    13
    '\x0d' (backslash x zero d: 0d is hexadecimal for 13)
    '\r'

(or the octal string escape represntation, or hex or octal immediates,
etc.)

The last is a special C-escape for CR and perhaps the most useful
representation since it describes the intended meaning here. (On the
other hand, this might not be appropriate if you're specifically dealing
with PC text files guaranteed to be 13-10 and the host system's CR might
not be 13 or something - I guess it's a style call.)

If you have ^M in the middle of a string then you should replace it with
a string constant escape such the latter two, \x0d or \r.

Rup.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Control M ????
  2002-02-12 13:11 Josh Perlmutter
@ 2002-02-12 16:31 ` Andrea 'Fyre Wyzard' Bocci
  0 siblings, 0 replies; 4+ messages in thread
From: Andrea 'Fyre Wyzard' Bocci @ 2002-02-12 16:31 UTC (permalink / raw)
  To: Josh Perlmutter, kabir.patel, me; +Cc: gcc-help

At 21.08 12/02/2002 (GMT +0000), Josh Perlmutter wrote:
>for some reason my last reply got screwed up and didn't go tot he list.
>
>for those interested, there's a little perl script i have that fixes this 
>problem.
>http://comp20.eecs.tufts.edu/jperlmut/
>"clean.pl"
>
>dl the instructions too. it's all there. that is from the cross enrollment 
>course  i took. i'm suprised they haven't taken it down.
>
>
>anyway, a lot of students at deis write progs one their windows boxes and 
>the ftp them to their cs account. one of my friends wrote the script to 
>get rid of those pesky ^M characters without doing the manual work.
>
>-Josh

If you have textutils installed, you can simply do

tr -d "\r" < input_file > output_file

This removes all the occurrences of ^M in the input file.

Alternativley,

tr "\r" " " < input_file > output_file

substitues all the ^M with spaces.

fwyzard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Control M ????
@ 2002-02-12 13:11 Josh Perlmutter
  2002-02-12 16:31 ` Andrea 'Fyre Wyzard' Bocci
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Perlmutter @ 2002-02-12 13:11 UTC (permalink / raw)
  To: kabir.patel, me; +Cc: gcc-help

for some reason my last reply got screwed up and didn't go tot he list.

for those interested, there's a little perl script i have that fixes this 
problem.
http://comp20.eecs.tufts.edu/jperlmut/
"clean.pl"

dl the instructions too. it's all there. that is from the cross enrollment 
course  i took. i'm suprised they haven't taken it down.


anyway, a lot of students at deis write progs one their windows boxes and 
the ftp them to their cs account. one of my friends wrote the script to get 
rid of those pesky ^M characters without doing the manual work.

-Josh


>From: kabir.patel@uk.andersen.com
>To: me@rupey.net
>CC: gcc-help@gcc.gnu.org
>Subject: Control M ????
>Date: Tue, 12 Feb 2002 12:07:56 +0000
>
>
>
>
>Some time back I mentioned a problem I had with the ^M character (see 
>below).
>It so happens that I need to be able to replace every ^M in my resultant 
>file
>with a " " charachter.
>GNU isn't happy with ^M. Is there a way to define ^M in another way?
>
>Thanks in advance
>
>
>
>
>
>Kabir Patel wrote:
>
> > Line 9469  while((pChar=strchr(Uwel_notes1.str,'^M'))!=NULL)
> > Line 9470             *(pChar) = *" ";
>
>Embedding a character 13 into the source is horrible and, as it happens,
>is causing this problem. (I also don't like the next line: there's no
>point dereferencing a constant string just for a space! This isn't a
>really bug, though - just style.)
>
>Try:
>
>     while((pChar=strchr(Uwel_notes1.str,'\r'))!=NULL)
>                *(pChar) = ' ';
>
>The problem was that the compiler was interpreting the ^M as a line
>break and not a character constant. It was trying to compile:
>
>     while((pChar=strchr(Uwel_notes1.str,'
>     '))!=NULL)
>
>and single-quoted constants may not cross line boundaries.
>
>Rup.
>
>
>
>
>
>
>
>
>*******************Internet Email Confidentiality Footer*******************
>
>
>Privileged/Confidential Information may be contained in this message.  If 
>you
>are not the addressee indicated in this message (or responsible for 
>delivery of
>the message to such person), you may not copy or deliver this message to 
>anyone.
>In such case, you should destroy this message and kindly notify the sender 
>by
>reply email. Please advise immediately if you or your employer does not 
>consent
>to Internet email for messages of this kind.  Opinions, conclusions and 
>other
>information in this message that do not relate to the official business of 
>my
>firm shall be understood as neither given nor endorsed by it.
>
>




*******************
Josh Perlmutter
NOC "intern"
Brandeis University


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Control M ????
@ 2002-02-12  4:30 kabir.patel
  0 siblings, 0 replies; 4+ messages in thread
From: kabir.patel @ 2002-02-12  4:30 UTC (permalink / raw)
  To: me; +Cc: gcc-help




Some time back I mentioned a problem I had with the ^M character (see below).
It so happens that I need to be able to replace every ^M in my resultant file
with a " " charachter.
GNU isn't happy with ^M. Is there a way to define ^M in another way?

Thanks in advance





Kabir Patel wrote:

> Line 9469  while((pChar=strchr(Uwel_notes1.str,'^M'))!=NULL)
> Line 9470             *(pChar) = *" ";

Embedding a character 13 into the source is horrible and, as it happens,
is causing this problem. (I also don't like the next line: there's no
point dereferencing a constant string just for a space! This isn't a
really bug, though - just style.)

Try:

    while((pChar=strchr(Uwel_notes1.str,'\r'))!=NULL)
               *(pChar) = ' ';

The problem was that the compiler was interpreting the ^M as a line
break and not a character constant. It was trying to compile:

    while((pChar=strchr(Uwel_notes1.str,'
    '))!=NULL)

and single-quoted constants may not cross line boundaries.

Rup.








*******************Internet Email Confidentiality Footer*******************


Privileged/Confidential Information may be contained in this message.  If you
are not the addressee indicated in this message (or responsible for delivery of
the message to such person), you may not copy or deliver this message to anyone.
In such case, you should destroy this message and kindly notify the sender by
reply email. Please advise immediately if you or your employer does not consent
to Internet email for messages of this kind.  Opinions, conclusions and other
information in this message that do not relate to the official business of my
firm shall be understood as neither given nor endorsed by it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-02-12 23:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <616BE6A276E3714788D2AC35C40CD18D3F2CB8@whale.softwire.co.uk>
2002-02-12  5:14 ` Control M ???? Rupert Wood
2002-02-12 13:11 Josh Perlmutter
2002-02-12 16:31 ` Andrea 'Fyre Wyzard' Bocci
  -- strict thread matches above, loose matches on Subject: below --
2002-02-12  4:30 kabir.patel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).