On Fri, 24 Nov 1995 myers@indy.net wrote:
> >
> > On Fri, 24 Nov 1995, Greg Alexander Irvine wrote:
> >
> > the problem isn't with the ^Ms, its with the program writing the ^Ms, i
> > suppose we could all put a dos2unix command for every file in autorun,
> > but that would be more hassle than its worth
>
>
> It seems more worthwhile to filter each string before it is written.
>
Yes, exactly. Why is it that you guys are finding it so hard to do this?
> A function to do so could be something like:
> void strip(char *string)
> {
[nice little function, deleted]
Ok, I consider myself to be an amatuer C programmer and I came up with
this program in five minutes! (give or take, and only because I've never
actually _used_ strtok() before and kept getting parse errors. d:-/ )
#include <stdio.h>
#include <string.h>
main()
{
char s1[] = "test\ring, th\ris works\r!\r";
char *p;
FILE *fp;
fp = fopen("strip.extra", "w+");
/* Look at all those ^M's! Uh oh... */
fprintf(fp, "%s", s1);
/* Let's get rid of them and print something we can read */
fprintf(fp, "\n\n%s", strtok(s1, "\r"));
while((p = strtok(NULL, "\r")) != NULL)
fprintf(fp, "%s", p);
fclose(fp);
}
/* THE END */
It doesn't actually get rid of the "\r" in the string, but then you don't
_want_ to do that if you're gonna use it to print to the mud users. Hmm,
ok, if you wanted to _read in_ the string putting the "\r"'s in the right
places I guess you'd have to write some token where they would be. Hell,
it only took 5 mins so maybe it's not perfect. I really don't know how
the olc works anyways cause I've never taken a look, sorry. d:-P But the
whole point is, it shouldn't take too long to do it. If it does, I
think you're doing something way too complicated...
This archive was generated by hypermail 2b30 : 12/07/00 PST