Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

getline() compilation issues

74 views
Skip to first unread message

Wee-Kiat Kong

unread,
Feb 6, 2003, 6:31:10 PM2/6/03
to
Hi everyone,

I'm trying to compile xcircuit (a circuit drawing and schematic capture
program) in Cygwin but in one of the source files (events.c), it uses
glibc's stdio function getline() which isn't found in newlib (which
Cygwin uses).

Can anyone suggest modifications to the following lines so that it will
compile using newlib?

else if (isbound(keywstate, XCF_Dashed))
getline(NULL, DASHED, NULL);
else if (isbound(keywstate, XCF_Dotted))
getline(NULL, DOTTED, NULL);
else if (isbound(keywstate, XCF_Solid))
getline(NULL, NORMAL, NULL);

BTW, if it'll help, you can get the xcircuit source files from
http://xcircuit.ece.jhu.edu/download.html

Thanks.

Ben Pfaff

unread,
Feb 6, 2003, 6:55:10 PM2/6/03
to
Wee-Kiat Kong <wk...@radlogic.com.au> writes:

> I'm trying to compile xcircuit (a circuit drawing and schematic capture
> program) in Cygwin but in one of the source files (events.c), it uses
> glibc's stdio function getline() which isn't found in newlib (which
> Cygwin uses).

[...]
> getline(NULL, DASHED, NULL);

That's not a correct invocation for glibc's getline(). I suspect
that xcircuit has its own function name getline().

By the way, getline() is not a standard C function, so
comp.lang.c is a poor place to discuss it.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}

Wee-Kiat Kong

unread,
Feb 6, 2003, 7:19:54 PM2/6/03
to
Ben Pfaff wrote:

> > I'm trying to compile xcircuit (a circuit drawing and schematic capture
> > program) in Cygwin but in one of the source files (events.c), it uses
> > glibc's stdio function getline() which isn't found in newlib (which
> > Cygwin uses).
> [...]
> > getline(NULL, DASHED, NULL);
>
> That's not a correct invocation for glibc's getline(). I suspect
> that xcircuit has its own function name getline().

There are only three lines in the source code with "getline" (I used grep -r
getline *) and none of them are function declarations.

Ben Pfaff

unread,
Feb 6, 2003, 7:26:38 PM2/6/03
to
Wee-Kiat Kong <wkong.nospam.@nospam.ozemail.com.au> writes:

Here's the prototype for glibc's getline:
ssize_t getline (char **LINEPTR, size_t *N, FILE *STREAM)
It doesn't make sense to pass a null pointer for the first or
third arguments, or to pass a macro or enumeration constant as
the second argument. You must be overlooking something.

Dan Pop

unread,
Feb 7, 2003, 7:00:13 AM2/7/03
to

>Wee-Kiat Kong <wkong.nospam.@nospam.ozemail.com.au> writes:
>
>> Ben Pfaff wrote:
>>
>> > > I'm trying to compile xcircuit (a circuit drawing and schematic capture
>> > > program) in Cygwin but in one of the source files (events.c), it uses
>> > > glibc's stdio function getline() which isn't found in newlib (which
>> > > Cygwin uses).
>> > [...]
>> > > getline(NULL, DASHED, NULL);
>> >
>> > That's not a correct invocation for glibc's getline(). I suspect
>> > that xcircuit has its own function name getline().
>>
>> There are only three lines in the source code with "getline" (I used grep -r
>> getline *) and none of them are function declarations.
>
>Here's the prototype for glibc's getline:
> ssize_t getline (char **LINEPTR, size_t *N, FILE *STREAM)
>It doesn't make sense to pass a null pointer for the first or
>third arguments, or to pass a macro or enumeration constant as
>the second argument.

There is no way to draw such conclusions from the prototype alone.
The specification of getline could very well define the behaviour when
LINEPTR and STREAM are null pointers. And with no clue about what DASHED
actually is, you can't know whether it is appropriate as the second
argument or not.

It is the actual documentation of getline that makes it clear that the
getline call above is broken: the first argument might point to a null
pointer, but it cannot be a null pointer itself and there is no definition
of behaviour when STREAM is a null pointer.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan...@ifh.de

Ben Pfaff

unread,
Feb 7, 2003, 1:51:37 PM2/7/03
to
Dan...@cern.ch (Dan Pop) writes:

> In <873cn1j...@pfaff.Stanford.EDU> Ben Pfaff <b...@cs.stanford.edu> writes:
>
> >Wee-Kiat Kong <wkong.nospam.@nospam.ozemail.com.au> writes:
> >
> >> Ben Pfaff wrote:
> >>
> >> > > I'm trying to compile xcircuit (a circuit drawing and schematic capture
> >> > > program) in Cygwin but in one of the source files (events.c), it uses
> >> > > glibc's stdio function getline() which isn't found in newlib (which
> >> > > Cygwin uses).
> >> > [...]
> >> > > getline(NULL, DASHED, NULL);
> >> >
> >> > That's not a correct invocation for glibc's getline(). I suspect
> >> > that xcircuit has its own function name getline().
> >>
> >> There are only three lines in the source code with "getline" (I used grep -r
> >> getline *) and none of them are function declarations.
> >
> >Here's the prototype for glibc's getline:
> > ssize_t getline (char **LINEPTR, size_t *N, FILE *STREAM)
> >It doesn't make sense to pass a null pointer for the first or
> >third arguments, or to pass a macro or enumeration constant as
> >the second argument.
>
> There is no way to draw such conclusions from the prototype alone.
> The specification of getline could very well define the behaviour when
> LINEPTR and STREAM are null pointers. And with no clue about what DASHED
> actually is, you can't know whether it is appropriate as the second
> argument or not.

Well, of course. I was trying to tell the OP that based on my
knowledge of what getline() actually does, not just from the
prototype.

0 new messages