473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

string splitting plzzzzzz help me...

xyz
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 -- srcaddress
22 --srcport
131.188.37.59 --destaddress
1398 --destport
tcp --protocol
168 --size
i need to split the string such that i need to get all these
parameters....
the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help
Jun 27 '08 #1
37 1795
On Apr 29, 4:24*pm, xyz <lavanyaredd...@gmail.comwrote:
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 * -- srcaddress
22 * * * * * * * * * * * *--srcport
131.188.37.59 * *--destaddress
1398 * * * * * * * * *--destport
tcp * * * * * * * * * *--protocol
168 * * * * * * * * *--size
i need to split the string such that i need to get all these
parameters....
*the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help
the clue is '.' so read function as many you want according to each
field...

Jun 27 '08 #2
xyz
On Apr 29, 1:24*pm, xyz <lavanyaredd...@gmail.comwrote:
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168
i have so many of such lines
for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 * -- srcaddress
22 * * * * * * * * * * * *--srcport
131.188.37.59 * *--destaddress
1398 * * * * * * * * *--destport
tcp * * * * * * * * * *--protocol
168 * * * * * * * * *--size
i need to split the string such that i need to get all these
parameters....
*the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help
Jun 27 '08 #3
On Apr 29, 2:24 pm, xyz <lavanyaredd...@gmail.comwrote:
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 -- srcaddress
22 --srcport
131.188.37.59 --destaddress
1398 --destport
tcp --protocol
168 --size
i need to split the string such that i need to get all these
parameters....
the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
Then post in <news:comp.lang.c++>, as it is not topical in this group.
i am not getting an idea how to split it..
You could start by splitting the spaces. Then determine which from the
splitted tokens are ipv4 addresses (do you care about ipv6?) and
strrchr(str, '.')
The solution seems very easy. I suggest you go back to learning the
basics before you start writing networking code.
Jun 27 '08 #4
On 29 Apr, 12:24, xyz <lavanyaredd...@gmail.comwrote:
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 * -- srcaddress
22 * * * * * * * * * * * *--srcport
131.188.37.59 * *--destaddress
1398 * * * * * * * * *--destport
tcp * * * * * * * * * *--protocol
168 * * * * * * * * *--size
i need to split the string such that i need to get all these
parameters....
*the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
strtok(), sscanf()?
operator>>() if you insist on C++
--
Nick Keighley

Jun 27 '08 #5
On Tue, 29 Apr 2008 06:42:59 -0700, Nick Keighley wrote:

This group is for C only:
take help from this example and convert this to C++

parsing of : comp.lang.c

#include<stdio.h>
#include<string.h>

int main()
{
char str[] = "comp.lang.c";
char *strParse;

printf("\n %s \n", str);

strParse = strtok(str, ".");

printf("strParse: %s\n", strParse);

strParse = strtok(NULL, ".");

printf("strParse: %s\n", strParse);

strParse = strtok(NULL, ".");

printf("strParse: %s\n", strParse);
return 0;
}


output :

comp.lang.c
strParse: comp
strParse: lang
strParse: c
Jun 27 '08 #6
On Tue, 29 Apr 2008 04:24:56 -0700 (PDT), xyz
<la************@gmail.comwrote:
>I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 -- srcaddress
22 --srcport
131.188.37.59 --destaddress
1398 --destport
tcp --protocol
168 --size
i need to split the string such that i need to get all these
parameters....
the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help
You have posted the same post four times in an hour. You are not
going to increase the level of response by being obnoxious. Show what
code you have developed so far and many will provide additional help.
Ask us to do the work for you and suffer in silence.
Remove del for email
Jun 27 '08 #7
On Apr 29, 4:24*pm, xyz <lavanyaredd...@gmail.comwrote:
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 * -- srcaddress
22 * * * * * * * * * * * *--srcport
131.188.37.59 * *--destaddress
1398 * * * * * * * * *--destport
tcp * * * * * * * * * *--protocol
168 * * * * * * * * *--size
i need to split the string such that i need to get all these
parameters....
*the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help
hi,
You can also use space (' ') to break the original strings and then
parse on the individual strings (after separating it on space taken)
to get your results.
- Ricky
Jun 27 '08 #8
xyz wrote:
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 -- srcaddress
22 --srcport
131.188.37.59 --destaddress
1398 --destport
tcp --protocol
168 --size
i need to split the string such that i need to get all these
parameters....
the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help
Well, I think plzzzzzz retired a few years ago, but maybe I can help.

Find below the portable C code of a program that splits a string very
similar to the one above into its components.

Enjoy.

/*
* strspl.c
*
* Copyright (c) 2008, John J. Smith
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose except in homework assignments
* is hereby granted without fee, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING AND NOT LIMITED TO ANY IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

/*
* PROBLEM:
*
* Message-ID: \
* <0d**********************************@d45g2000hsc. googlegroups.com>
* From: xyz <lavanyareddy[dot]p[at]gmail.com>
*
* I have a string
* 16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168
*
* for example lets say for the above string
* 16:23:18.659343 -- time
* 131.188.37.230 -- srcaddress
* 22 -- srcport
* 131.188.37.59 -- destaddress
* 1398 -- destport
* tcp -- protocol
* 168 -- size
* i need to split the string such that i need to get all these
* parameters....
* the field widths are not fixed..i have some times four/three digits
* srcport ..so i cant do it with substr function...i need this in c++
* i am not getting an idea how to split it..
* thank you for any help
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>

static const char *example_string =
"16:23:18.659343 131.188.37.230 22 131.188.37.59 1398 tcp 168";

void solve_problem(char *, ...);

static const char *ptr(const char *p, char c)
{
if(!c) return p + strlen(p) + 1;
while(*p && *p != c) p++;
while(*p == c) p++;
if(!*p)
solve_problem("character %c not found in string %s!", c, p);
return p;
}

static void *xmalloc(size_t sz)
{
char *new = malloc(sz);
if(!new)
solve_problem("unable to allocate %lu bytes of memory", (unsigned long)sz);
*(sz - 1 + new) = '\0';
return new;
}

static char *wtof(const char *w, size_t size)
{
char *f;
while(w[size-1] == ' ') size--;
f = xmalloc(size+1);
memcpy(f, w, size);
return f;
}

void split(
const char *string,
char **blue_goo,
char **green_goo,
char **purple_goo,
char **red_goo,
char **glowing_goo,
char **foo_goo,
char **goo_goo )
{
const char *w[8]; char *f[7]; int i;

w[0] = string;
for(i = 1; i < 7; i++)
w[i] = ptr(w[i-1], ' ');
w[7] = ptr(w[6], '\0');

for(i = 0; i < 7; i++)
f[i] = wtof(w[i], w[i+1]-w[i]-1);

*blue_goo = 0[f]; *green_goo = f[1]; *purple_goo = 2[f];
*red_goo = f[3]; *glowing_goo = 4[f]; *foo_goo = f[5];
*goo_goo = 6[f];
}

int main(void)
{
char *p[7]; int i;

fprintf(stdout,
"splitting \"%s\",\n"
" please wait...\n",
example_string);
split(example_string, p+0, 1+p, p+2, 3+p, p+4, 5+p, p+6);

fprintf(stdout,
"result is\n"
" time: \"%s\"\n"
" src addr: \"%s\"\n"
" src port: \"%s\"\n"
" dst addr: \"%s\"\n"
" dst port: \"%s\"\n"
" protocol: \"%s\"\n"
" size: \"%s\"\n",
0[p], p[1], 2[p], p[3], 4[p], p[5], 6[p]);

fprintf(stdout, "freeing memory...\n");
for(i = 0; i < 7; i++)
free(i[p]);

fprintf(stdout, "all done.\n");
return 0;
}

void solve_problem(char *problem, ...)
{
va_list ap;
va_start(ap, problem);
va_end(ap);
if(problem) {
fprintf(stderr, "dirty disk!\n");
abort();
}
}
/* end strspl.c */

--
John J. Smith
String Splitter

Jun 27 '08 #9
xyz wrote:
I have a string
16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168

for example lets say for the above string
16:23:18.659343 -- time
131.188.37.230 -- srcaddress
22 --srcport
131.188.37.59 --destaddress
1398 --destport
tcp --protocol
168 --size
i need to split the string such that i need to get all these
parameters....
the field widths are not fixed..i have some times four/three digits
srcport ..so i cant do it with substr function...i need this in c++
i am not getting an idea how to split it..
thank you for any help
Easy!

#! /usr/bin/perl -W

$string = '16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168';

sub _split($) {
my ( $s ) = @_;
if( $s =~ / ^(\d+:\d+:\d+\.\d+)\ #
(\d+\.\d+\.\d+\.\d+)\.(\d+)\ #
(\d+\.\d+\.\d+\.\d+)\.(\d+)\ #
(\w+)\ #
(\d+)$
/x ) {
return ( $1, $2, $3, $4, $5, $6, $7 );
} else {
return ();
}
}

my @res = _split $string ;
foreach( @res ) {
print "$_\n";
}
Jun 27 '08 #10
John J. Smith schrieb:
Find below the portable C code of a program that splits a string very
similar to the one above into its components.
This program has 2 errors! It compiles not with LCC-WIN32.

lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
Warning strspl.c: 73 inconsistent linkage for 'wtof' previously declared at c:\lcc\include\stdlib.h 55
2 errors, 1 warning
1 error

You are redefining a function in stdlib.h

Why are your programs always not working with LCC-WIN32?

Enjoy.

/*
* strspl.c
*
* Copyright (c) 2008, John J. Smith
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose except in homework assignments
* is hereby granted without fee, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING AND NOT LIMITED TO ANY IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

/*
* PROBLEM:
*
* Message-ID: \
* <0d**********************************@d45g2000hsc. googlegroups.com>
* From: xyz <lavanyareddy[dot]p[at]gmail.com>
*
* I have a string
* 16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168
*
* for example lets say for the above string
* 16:23:18.659343 -- time
* 131.188.37.230 -- srcaddress
* 22 -- srcport
* 131.188.37.59 -- destaddress
* 1398 -- destport
* tcp -- protocol
* 168 -- size
* i need to split the string such that i need to get all these
* parameters....
* the field widths are not fixed..i have some times four/three digits
* srcport ..so i cant do it with substr function...i need this in c++
* i am not getting an idea how to split it..
* thank you for any help
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>

static const char *example_string =
"16:23:18.659343 131.188.37.230 22 131.188.37.59 1398 tcp 168";

void solve_problem(char *, ...);

static const char *ptr(const char *p, char c)
{
if(!c) return p + strlen(p) + 1;
while(*p && *p != c) p++;
while(*p == c) p++;
if(!*p)
solve_problem("character %c not found in string %s!", c, p);
return p;
}

static void *xmalloc(size_t sz)
{
char *new = malloc(sz);
if(!new)
solve_problem("unable to allocate %lu bytes of memory", (unsigned
long)sz);
*(sz - 1 + new) = '\0';
return new;
}

static char *wtof(const char *w, size_t size)
{
char *f;
while(w[size-1] == ' ') size--;
f = xmalloc(size+1);
memcpy(f, w, size);
return f;
}

void split(
const char *string,
char **blue_goo,
char **green_goo,
char **purple_goo,
char **red_goo,
char **glowing_goo,
char **foo_goo,
char **goo_goo )
{
const char *w[8]; char *f[7]; int i;

w[0] = string;
for(i = 1; i < 7; i++)
w[i] = ptr(w[i-1], ' ');
w[7] = ptr(w[6], '\0');

for(i = 0; i < 7; i++)
f[i] = wtof(w[i], w[i+1]-w[i]-1);

*blue_goo = 0[f]; *green_goo = f[1]; *purple_goo = 2[f];
*red_goo = f[3]; *glowing_goo = 4[f]; *foo_goo = f[5];
*goo_goo = 6[f];
}

int main(void)
{
char *p[7]; int i;

fprintf(stdout,
"splitting \"%s\",\n"
" please wait...\n",
example_string);
split(example_string, p+0, 1+p, p+2, 3+p, p+4, 5+p, p+6);

fprintf(stdout,
"result is\n"
" time: \"%s\"\n"
" src addr: \"%s\"\n"
" src port: \"%s\"\n"
" dst addr: \"%s\"\n"
" dst port: \"%s\"\n"
" protocol: \"%s\"\n"
" size: \"%s\"\n",
0[p], p[1], 2[p], p[3], 4[p], p[5], 6[p]);

fprintf(stdout, "freeing memory...\n");
for(i = 0; i < 7; i++)
free(i[p]);

fprintf(stdout, "all done.\n");
return 0;
}

void solve_problem(char *problem, ...)
{
va_list ap;
va_start(ap, problem);
va_end(ap);
if(problem) {
fprintf(stderr, "dirty disk!\n");
abort();
}
}
/* end strspl.c */
Jun 27 '08 #11
Hans Schneider wrote:
John J. Smith schrieb:
Find below the portable C code of a program that splits a
string very similar to the one above into its components.

This program has 2 errors! It compiles not with LCC-WIN32.
Lcc-win32, or at least your copy of it, has errors.
lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
Warning strspl.c: 73 inconsistent linkage for 'wtof' previously
declared at c:\lcc\include\stdlib.h 55
2 errors, 1 warning
1 error

You are redefining a function in stdlib.h
No, the lcc standard library is breaking conformance by declaring
and defining a function outside of the implementation namespace.
That is not John's fault.

--
Peter
Jun 27 '08 #12
Hans Schneider <ha**@localhost.localdomainwrites:
John J. Smith schrieb:
>Find below the portable C code of a program that splits a string very
similar to the one above into its components.

This program has 2 errors! It compiles not with LCC-WIN32.

lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
Warning strspl.c: 73 inconsistent linkage for 'wtof' previously declared at c:\lcc\include\stdlib.h 55
2 errors, 1 warning
1 error

You are redefining a function in stdlib.h

Why are your programs always not working with LCC-WIN32?
[...]

"wtof" is not defined in the C standard, and a conforming
implementation is not allowed to declare it in <stdlib.h>.

Perhaps this is corrected in a newer version of lcc-win32? As a
workaround, you can change the name "wtof" to something else.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #13
Hans Schneider wrote:
John J. Smith schrieb:
>Find below the portable C code of a program that splits a string
very similar to the one above into its components.

This program has 2 errors! It compiles not with LCC-WIN32.

lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
Warning strspl.c: 73 inconsistent linkage for 'wtof' previously declared at c:\lcc\include\stdlib.h 55
2 errors, 1 warning
1 error

You are redefining a function in stdlib.h

Why are your programs always not working with LCC-WIN32?
Probably because LCC-WIN32 fails to observe the C standard. There
is no such function as "wtof" in the C library.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #14
CBFalconer <cb********@yahoo.comwrites:
Hans Schneider wrote:
>John J. Smith schrieb:
>>Find below the portable C code of a program that splits a string
very similar to the one above into its components.

This program has 2 errors! It compiles not with LCC-WIN32.

lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
Warning strspl.c: 73 inconsistent linkage for 'wtof' previously declared at c:\lcc\include\stdlib.h 55
2 errors, 1 warning
1 error

You are redefining a function in stdlib.h

Why are your programs always not working with LCC-WIN32?

Probably because LCC-WIN32 fails to observe the C standard. There
is no such function as "wtof" in the C library.
But it is still valid C I think. This is a C news group.
Jun 27 '08 #15
Eligiusz Narutowicz said:
CBFalconer <cb********@yahoo.comwrites:
>Hans Schneider wrote:
>>John J. Smith schrieb:

Find below the portable C code of a program that splits a string
very similar to the one above into its components.

This program has 2 errors! It compiles not with LCC-WIN32.

lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
Warning strspl.c: 73 inconsistent linkage for 'wtof' previously
declared at c:\lcc\include\stdlib.h 55 2 errors, 1 warning
1 error

You are redefining a function in stdlib.h

Why are your programs always not working with LCC-WIN32?

Probably because LCC-WIN32 fails to observe the C standard. There
is no such function as "wtof" in the C library.

But it is still valid C I think. This is a C news group.
Um, yes - that's the problem. The program had a wtof function. The name
'wtof' is in user namespace, and no C implementation is permitted to
invade that space. The lcc-win32 implementation, by doing so, fails
(again!) to conform to the definition of the C language. This is one of
many lcc-win32 conformance issues to be posted here in a comparatively
short time, and the maintainer's attitude seems to be that he only fixes
bugs reported by paying customers.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #16
Richard Heathfield wrote:
This is one of
many lcc-win32 conformance issues to be posted here in a comparatively
short time, and the maintainer's attitude seems to be that he only fixes
bugs reported by paying customers.
My understanding was that any alleged bug reported by a CLC regular
was in fact treated as a vile attack on the integrity of the maintainer,
and thus either ignored or insulted. ICBW.
Jun 27 '08 #17
Richard Heathfield wrote:
Eligiusz Narutowicz said:
>CBFalconer <cb********@yahoo.comwrites:
>>Hans Schneider wrote:
John J. Smith schrieb:

Find below the portable C code of a program that splits a string
very similar to the one above into its components.
This program has 2 errors! It compiles not with LCC-WIN32.

lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
Warning strspl.c: 73 inconsistent linkage for 'wtof' previously
declared at c:\lcc\include\stdlib.h 55 2 errors, 1 warning
1 error

You are redefining a function in stdlib.h

Why are your programs always not working with LCC-WIN32?
Probably because LCC-WIN32 fails to observe the C standard. There
is no such function as "wtof" in the C library.
But it is still valid C I think. This is a C news group.

Um, yes - that's the problem. The program had a wtof function. The name
'wtof' is in user namespace, and no C implementation is permitted to
invade that space. The lcc-win32 implementation, by doing so, fails
(again!) to conform to the definition of the C language. This is one of
many lcc-win32 conformance issues to be posted here in a comparatively
short time, and the maintainer's attitude seems to be that he only fixes
bugs reported by paying customers.
You are lying, as always.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08 #18
Mark McIntyre wrote:
Richard Heathfield wrote:
>This is one of many lcc-win32 conformance issues to be posted
here in a comparatively short time, and the maintainer's attitude
seems to be that he only fixes bugs reported by paying customers.

My understanding was that any alleged bug reported by a CLC
regular was in fact treated as a vile attack on the integrity of
the maintainer, and thus either ignored or insulted. ICBW.
s/either or/normally and/

I don't believe I have ever seen 'thank you' or 'merci' in the
response.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #19
Hans Schneider wrote:
John J. Smith schrieb:
>Find below the portable C code of a program that splits a string very
similar to the one above into its components.

This program has 2 errors! It compiles not with LCC-WIN32.

lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here
(?)
Aren't these two diagnostics referring to the same problem?

Why is the implementation in question *defining* (rather than declaring)
things inside a standard header?

On second thought, the second diagnostic appears to be reporting a
problem in "c:\lcc\include\stdlib.h" at line 55.

Warning strspl.c: 73 inconsistent linkage for 'wtof' previously declared\
at c:\lcc\include\stdlib.h 55
2 errors, 1 warning
1 error
^^^^^^^
What is this third error?

You are redefining a function in stdlib.h
Seems like I do, but I don't think <stdlib.hshould be
declaring/defining a symbol of that name; at least not if
the compiler is invoked in a standards-conforming mode.
(Out of curiosity, what is wtof() documented to be doing?)

Why are your programs always not working with LCC-WIN32?
To be honest, that's a good question. I have no idea.

Since my main development machine is a Sun4 (plus a Sun3 and
SGI Indy and a couple of historic unices), I'm afraid I can't
easily test my code on lcc-win without jumping through lots of
hoops (As it seems the free download is a Win32 executable, I
can't even unpack it and have a look at the included <stdlib.h>).

Perhaps I should add another disclaimer to the effect that
although the code is standards conform, it may or may not be
compatible with every C implementation out there.

[snip code you quoted but didn't comment on]

--
John J. Smith

Jun 27 '08 #20
jacob navia said:
Richard Heathfield wrote:
>Eligiusz Narutowicz said:
>>CBFalconer <cb********@yahoo.comwrites:

Hans Schneider wrote:
<snip>
>>>>>
Why are your programs always not working with LCC-WIN32?
Probably because LCC-WIN32 fails to observe the C standard. There
is no such function as "wtof" in the C library.
But it is still valid C I think. This is a C news group.

Um, yes - that's the problem. The program had a wtof function. The name
'wtof' is in user namespace, and no C implementation is permitted to
invade that space. The lcc-win32 implementation, by doing so, fails
(again!) to conform to the definition of the C language. This is one of
many lcc-win32 conformance issues to be posted here in a comparatively
short time, and the maintainer's attitude seems to be that he only fixes
bugs reported by paying customers.

You are lying, as always.
By saying (wrongly) that I am lying, which of the following statements are
you attempting to imply?

(a) the name wtof is not in user namespace;
(b) implementations are allowed to invade user namespace;
(c) lcc-win32 does not invade user namespace;
(d) lcc-win32 hasn't had many conformance issues reported here recently;
(e) you fix bugs with lcc-win32, no matter who reports them.

No doubt your answer will provide a fascinating insight into your model of
reality.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #21
CBFalconer wrote:
Mark McIntyre wrote:
>Richard Heathfield wrote:
>>This is one of many lcc-win32 conformance issues to be posted
here in a comparatively short time, and the maintainer's attitude
seems to be that he only fixes bugs reported by paying customers.
My understanding was that any alleged bug reported by a CLC
regular was in fact treated as a vile attack on the integrity of
the maintainer, and thus either ignored or insulted. ICBW.

s/either or/normally and/

I don't believe I have ever seen 'thank you' or 'merci' in the
response.
go to hell falconer

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08 #22
John J. Smith <jj*@localhost.invalidwrote:
Hans Schneider wrote:
>>
lc -ansic -A -shadows -unused -O -c strspl.c -o strspl.obj
Error strspl.c: 73 redefinition of 'wtof'
Error c:\lcc\include\stdlib.h: 55 Previous definition of 'wtof' here

Why is the implementation in question *defining* (rather than declaring)
things inside a standard header?
It's not -- the compiler's error messages are misleading.
(Out of curiosity, what is wtof() documented to be doing?)
Presumably, it's the wide character version of atof() -- it converts a
wide string to a double. It seems to be a Microsoftism, but recent
versions of MSC at least seem to spell it _wtof(), which avoids
polluting the user's namespace.
>Why are your programs always not working with LCC-WIN32?
Because LCC-WIN32 doesn't conform to the C Standard in lots of little
ways. Whether that's due to ignorance, carelessness, or just
prioritization relative to other things, I'll leave to you to judge.

-- Larry Jones

Please tell me I'm adopted. -- Calvin
Jun 27 '08 #23
rio

"jacob navia" <ja***@nospam.comha scritto nel messaggio
news:fv**********@aioe.org...
CBFalconer wrote:
>Mark McIntyre wrote:
>>Richard Heathfield wrote:

This is one of many lcc-win32 conformance issues to be posted
here in a comparatively short time, and the maintainer's attitude
seems to be that he only fixes bugs reported by paying customers.
My understanding was that any alleged bug reported by a CLC
regular was in fact treated as a vile attack on the integrity of
the maintainer, and thus either ignored or insulted. ICBW.

s/either or/normally and/

I don't believe I have ever seen 'thank you' or 'merci' in the
response.
go to hell falconer
i think falconer is a good programmer (possibly an assembly programmer)
the only little defect i found
is that falconer think to be right always (and this can not be true
for nobody of us here)
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32


Jun 27 '08 #24
Keith Thompson wrote:
Perhaps this is corrected in a newer version of lcc-win32?
I keep reading that some problems may be corrected in newer versions,
but for some time now (at least since early 2008) I am unable to
download anything lcc-win32 related.

The link in J.N.'s signature leads to

[1] <http://www.cs.virginia.edu/~lcc-win32/.
If I click on "lcc-win32" further down on that page, I'm taken to

[2] <http://www.q-software-solutions.de/downloaders/get_name,

which has a button at the bottom labeled "Get me to the Downloads".
Clicking on that opens up

[3] <http://www.q-software-solutions.de/downloaders/show_download_locations,

but choosing any download but "Changes" takes me back to [2], where
clicking on "Get me to the Downloads" opens up [3] again, etc, etc, etc...
At least from where I am there is no way to get a newer version.

Where did lcc-win32 users in c.l.c download the current free version?

--
T.Pot.

Jun 27 '08 #25
On 2 May, 21:55, CBFalconer <cbfalco...@yahoo.comwrote:
Mark McIntyre wrote:
Richard Heathfield wrote:
This is one of many lcc-win32 conformance issues to be posted
here in a comparatively short time, and the maintainer's attitude
seems to be that he only fixes bugs reported by paying customers.
to be fair the implementor of lcc-win32 modified this policy
(if indeed it ever was his policy). He has stated that he was being
sarcastic when he claimed he wouldn't fix anything reported by
a clc regular. Sarcasm is always a tricky thing on usenet
and the implementor of lcc-win32 seems to be particularly
bad at it.

I believe the policy of the implementor of lcc-win32
is that he will fix bugs reported by whomever. But he will
not undertake major development except in support of a paying
customer. This seems fair enough.

Of course there may be disagreements on what a "bug" actually
is...

I believe what triggered the sarcasm was a complaint
that lcc-win32 didn't run an a particularly ancient
version of Windows. Fair enough if its clear that old
platforms aren't supported.

My understanding was that any alleged bug reported by a CLC
regular was in fact treated as a vile attack on the integrity of
the maintainer, and thus either ignored or insulted. ICBW.

s/either or/normally and/

I don't believe I have ever seen 'thank you' or 'merci' in the
response.

--
Nick Keighley

Jun 27 '08 #26
Nick Keighley <ni******************@hotmail.comwrote:
>
I believe the policy of the implementor of lcc-win32
is that he will fix bugs reported by whomever.
But only after ridiculing the reporter, displaying his ignorance of (the
finer points of?) the C Standard, and ranting and raving in his
charmingly paranoid fashion about how certain people here are always
picking on him and his compiler. At least for bugs that are reported
here.

I give him credit for eventually fixing the bugs, but it would be
refreshing to see a response of, "Yes, you're right. I'll fix it.",
without having to go through the usual flame fest first.

-- Larry Jones

In a minute, you and I are going to settle this out of doors. -- Calvin
Jun 27 '08 #27
teapot wrote, On 06/05/08 14:47:
Keith Thompson wrote:
>Perhaps this is corrected in a newer version of lcc-win32?

I keep reading that some problems may be corrected in newer versions,
but for some time now (at least since early 2008) I am unable to
download anything lcc-win32 related.
<snip problems trying to download lcc-win32>

I suggest emailing Jacob directly or asking on comp.compilers.lcc in
case he does not see your question here. I've cross-posted and set
follow-ups for you.
--
Flash Gordon
Jun 27 '08 #28
la************@siemens.com wrote:
Nick Keighley <ni******************@hotmail.comwrote:
>I believe the policy of the implementor of lcc-win32
is that he will fix bugs reported by whomever.

But only after ridiculing the reporter, displaying his ignorance of (the
finer points of?) the C Standard, and ranting and raving in his
charmingly paranoid fashion about how certain people here are always
picking on him and his compiler. At least for bugs that are reported
here.
Not only that, there are things I will not even fix at all.
For instance, the undocumented "-ansic89" option...

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08 #29
jacob navia <ja***@nospam.comwrites:
la************@siemens.com wrote:
>Nick Keighley <ni******************@hotmail.comwrote:
>>I believe the policy of the implementor of lcc-win32
is that he will fix bugs reported by whomever.

But only after ridiculing the reporter, displaying his ignorance of (the
finer points of?) the C Standard, and ranting and raving in his
charmingly paranoid fashion about how certain people here are always
picking on him and his compiler. At least for bugs that are reported
here.

Not only that, there are things I will not even fix at all.
For instance, the undocumented "-ansic89" option...
For the record, jacob, am I correct in assuming that lcc-win does
*not* have, and is not intended to have, a mode in which it fully
conforms to the (officially obsolete) ANSI C89 / ISO C90 standard(s)?

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #30
Keith Thompson wrote:
>
For the record, jacob, am I correct in assuming that lcc-win does
*not* have, and is not intended to have, a mode in which it fully
conforms to the (officially obsolete) ANSI C89 / ISO C90 standard(s)?
I have NO idea where Mr Teapot got to know that option. It is not in the
documentation!

Somehow he has access to some source code. I searched all the available
documents and there is NO MENTION of that option.

But maybe I forgot something. In any case it is obvious that I will not
support that. Somehow, after all the C99 implementation effort it is
impossible to consider trying to eliminate // comments from the
compiler.

Besides I do not feel like wasting my time on it. Of course, if Mr
Teapot has money to burn, I would do it in a specially prepared
lcc-win version...

:-)
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08 #31
jacob navia <ja***@nospam.comwrites:
Keith Thompson wrote:
>For the record, jacob, am I correct in assuming that lcc-win does
*not* have, and is not intended to have, a mode in which it fully
conforms to the (officially obsolete) ANSI C89 / ISO C90 standard(s)?

I have NO idea where Mr Teapot got to know that option. It is not in the
documentation!

Somehow he has access to some source code. I searched all the available
documents and there is NO MENTION of that option.

But maybe I forgot something. In any case it is obvious that I will not
support that. Somehow, after all the C99 implementation effort it is
impossible to consider trying to eliminate // comments from the
compiler.

Besides I do not feel like wasting my time on it. Of course, if Mr
Teapot has money to burn, I would do it in a specially prepared
lcc-win version...

:-)
I was looking for a simple yes or no answer, not a rant. Sheesh!

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #32
jacob navia <ja***@nospam.comwrites:
Keith Thompson wrote:
>>
For the record, jacob, am I correct in assuming that lcc-win does
*not* have, and is not intended to have, a mode in which it fully
conforms to the (officially obsolete) ANSI C89 / ISO C90 standard(s)?

I have NO idea where Mr Teapot got to know that option. It is not in the
documentation!

Somehow he has access to some source code.
That is a leap too far. 'strings lcc.exe| grep ansi' outputs -ansi89
and -ansic. I do it all the time if I can't remember the spelling of
an option and there is no convenient 'man lcc' command. -ansic is
different enough from what I'd expect that I might have done this
myself (although, in fact, I had not until today).

--
Ben.
Jun 27 '08 #33
On 6 May 2008 at 21:53, jacob navia wrote:
I have NO idea where Mr Teapot got to know that option. It is not in the
documentation!

Somehow he has access to some source code. I searched all the available
documents and there is NO MENTION of that option.
$ strings ~/.wine/drive_c/lcc/bin/lcc.exe | grep -- ^- | grep '[:alpha:]' | sort -u
-8lH
-alignfn
-ansi89
-ansic
-boundscheck
-check
-coverage
-export:%s
-finline
-fno-inline
-hDl]
-libcdll
-library:%s
-noregistrylookup
-overflowcheck
-pedantic
-profile
-shadows
-stackinit
-trapuv
Are there any other undocumented options in that list? :)

Jun 27 '08 #34
Keith Thompson said:
jacob navia <ja***@nospam.comwrites:
<snip>
>Somehow, after all the C99 implementation effort it is
impossible to consider trying to eliminate // comments from the
compiler.

Besides I do not feel like wasting my time on it. Of course, if Mr
Teapot has money to burn, I would do it in a specially prepared
lcc-win version...

:-)

I was looking for a simple yes or no answer, not a rant. Sheesh!
What you got, however, was confirmation that lcc-win32 doesn't conform to
C90 - and it is already known that it does not yet conform to C99.
Therefore, it is not a C compiler.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #35
Richard Heathfield wrote:
Keith Thompson said:
>jacob navia <ja***@nospam.comwrites:

<snip>
>>Somehow, after all the C99 implementation effort it is
impossible to consider trying to eliminate // comments from the
compiler.

Besides I do not feel like wasting my time on it. Of course, if
Mr Teapot has money to burn, I would do it in a specially
prepared lcc-win version...

I was looking for a simple yes or no answer, not a rant. Sheesh!

What you got, however, was confirmation that lcc-win32 doesn't
conform to C90 - and it is already known that it does not yet
conform to C99. Therefore, it is not a C compiler.
And where can you find a compiler that meets all those specs?
Without a generally apporoved public domain test suite it is
impossible to even test for such. Well, impracticable at least.
What we CAN do is find particular bugs and failings, and report
those.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #36
CBFalconer wrote, On 07/05/08 16:55:
Richard Heathfield wrote:
>Keith Thompson said:
>>jacob navia <ja***@nospam.comwrites:
<snip>
>>>Somehow, after all the C99 implementation effort it is
impossible to consider trying to eliminate // comments from the
compiler.

Besides I do not feel like wasting my time on it. Of course, if
Mr Teapot has money to burn, I would do it in a specially
prepared lcc-win version...
I was looking for a simple yes or no answer, not a rant. Sheesh!
What you got, however, was confirmation that lcc-win32 doesn't
conform to C90 - and it is already known that it does not yet
conform to C99. Therefore, it is not a C compiler.

And where can you find a compiler that meets all those specs?
Richard was not suggesting that it should meet all of them, only that it
should (modulo bugs) meet at least one.
Without a generally apporoved public domain test suite it is
impossible to even test for such. Well, impracticable at least.
What we CAN do is find particular bugs and failings, and report
those.
As yet lcc-win32 does not claim to fully implement *any* version of the
C standard since Jacob acknowledges he has not yet finished implementing
C99 and he does not make any claim about supporting earlier standards.

If you look at any of gcc, MSVC++, Borland C++, icc and a whole host of
others you will find that they claim to implement at least one version
of the standard (when appropriately poked) and modulo bugs (as opposed
to things not implemented) this is what they do.

So the position with lcc-win32 *is* different, and will remain so until
Jacob believes that he has finished implementing C99.

Of course, there are also compilers for embedded systems that do not
fully implement any version of the C standard, so Jacob is not entirely
unique in this respect.
--
Flash Gordon
Jun 27 '08 #37
Flash Gordon wrote:
CBFalconer wrote, On 07/05/08 16:55:
.... snip ...
>
>And where can you find a compiler that meets all those specs?

Richard was not suggesting that it should meet all of them, only
that it should (modulo bugs) meet at least one.
>Without a generally apporoved public domain test suite it is
impossible to even test for such. Well, impracticable at least.
What we CAN do is find particular bugs and failings, and report
those.

As yet lcc-win32 does not claim to fully implement *any* version
of the C standard since Jacob acknowledges he has not yet
finished implementing C99 and he does not make any claim about
supporting earlier standards.
I wasn't harassing Jacob and lcc-win32. I was moaning about the
absence of a public domain agreed upon test suite.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #38

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anat | last post by:
Hi, I need a little help on performing string manipulation: I want to take a given string, and make certain words hyperlinks. For example: "Hello world, this is a wonderful day!" I'd like the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.