Look for open source C library for text manipulation

S

Spiros Bousbouras

It is indeed quite common for people to refer to libraries
by referring to the header. It is wrong to do so. It is
extremely common for people to be so totally ignorant of
how libraries work and to indeed believe that the header
is the library. How many times have you heard someone
complain "my program won't compile and it complains
about 'undefined function: log', but I included
math.h"? I've lost count of the number of times
I've had to explain it, and I would prefer that more
people understand the very simple idea that the
header is not the library. Too many people confuse
the two. I believe that jackassp does not understand
the distinction. Perhaps I am wrong about that.


You are correct. Perhaps my first post should have been more
explicit, and I ought to have written, "perhaps you are referring
to some third party library named libregex...", since I was not
assuming any reference to SUS.

If your intention was to be helpful to someone who is
inexperienced then a phrase like "perhaps you are referring to
some third party library named libregex..." would be just as
pointless and unhelpful as what you actually wrote. I am
perfectly aware that some times you have to include extra flags
to link with a library yet I thought that
"regex.h is a header, not a library. Very likely you are
referring to libregex, whose API is published in a file
named regex.h"
was just a pedantic remark on the "proper" way to refer to things.
In no way does it lead anyone to think that including the header
may not be enough. A genuinely helpful remark would be something
like
"Note that the header (regex.h in this case) is not the
library. To see why the distinction is important look at
question 13.25 of the FAQ (http://c-faq.com)"
Note that even such a comment, although it cannot be accused of
pedantry, still runs the danger of offending some people because
it implies that they are beginners.

S N I P
I disagree. Jackassp's post was inaccurate. If he wanted the
OP to use functions from an implementation's libc which are
declared in that implementation's <regex.h>, then he ought
to have written "use functions from regex.h". Or perhaps,
"use libc functions declared in regex.h".

If you refer to "the math.h library", or "the stdio.h library",
or "the regex.h library", you only contribute to confusion.

I agree that Jackassp's post was not 100% accurate. But the
difference between 100% accuracy and what he wrote is a pedantic
one. On the other hand I do not agree that Jackassp's post
contributes to any confusion. His intention was simply to
provide a reference to a library which might perform what the OP
wants. His intention was **not** to provide information on how
such a library should be linked. There is nothing in what he
said to suggest that including the header is enough for the
library to be linked properly. It may or may not be enough but
this is a question completely independent from what the OP asked
and what Jackass answered. If anyone were to draw conclusions on
how a library should be linked from what Jackass said then that
person would be simply jumping to conclusions.
I believe this thread is the first time I've ever been accused
of pedantry. I'll accept that I was inaccurate, since I ought
to have explicitly pointed out that the 'libregex' I was referring
to was a purely fictional name for a library that would reasonably
go with a header named 'regex.h', but I don't don't accept
either that I am being pedantic or that my caution is misplaced.

I accept that your motivation was not pedantry but it certainly
came across as pedantry and in any case it offered nothing
towards guiding an inexperienced C programmer on how to link a
library.
If the day ever comes that no newbie programmer is ever
confused about why he needs to add a -lfoo to CFLAGS
when the source code clearly includes foo.h, then I won't
correct someone who refers to the "foo.h library". Until
then, it is necessary to refer to headers as headers, and
libraries as libraries.

Not every post can or should try to address every misconception
some newbie may possibly have. When the purpose is to denote a
library then mentioning the header is adequate (assuming the
header name itself is unambiguous).
 
S

Spiros Bousbouras

I very much regret not having access to the comp.lang.c resource
when I first set out to learn C. This blurring between headers and
libraries certainly confused me at first. I would have appreciated
having the distinction set out clearly for me in the early days.

Which William Pursell's comment did not do.
 
S

Spiros Bousbouras

Spiros Bousbouras said:



It seems to me that you are now criticising Mr Pursell for being
both too pedantic and not pedantic enough. Tough crowd.

Now I am criticising him for failing to be helpful (which
was his intention) and ending up being pedantic
instead.
 
B

Barry Schwarz

Hopefully the replies have proven to you that the only confusion is
emanating from your direction. You appear to be confused (as well as
mistaken) in thinking that referring to a header as a library in a
technical C programming group would, in any way, confuse anyone.

I guess the numerous posts that demonstrate that beginners frequently
suffer from this confusion doesn't affect your argument at all.
 
G

Guest

WTF? I'm attempting to prevent people from being confused.
What do you even mean 'attempting to score points'? Why are you
people so obsessed with the idea that some cabal of people
hold a grip on this newsgroup that you need to break? Sure, there
are annoying twits like CBF who jump into every thread and
complain about topicality or invalid signature lines or
yammer on about pointless crap, but..WTF?

A ridiculously large number of people don't understand the
difference between a library and a header. People will
often say "my program won't compile because it can't
find the sin function, but I included <math.h>". The
wording of jackassp's post (and his name) indicate that
he is probably confused about the distinction, and I
thought it could quelch some confusion by pointing out
the distinction

another goodie is "I don't have regexp.h on my system
where can I download it from?". Such a person is probably
very confused.

Though I have to confess most people would have understood
"use the regexp.h library"
 
G

Guest

William Pursell said:


And it's wrong because there's a real comprehension cost for newbies
in being misled by such people.

You're right, in other words. Now you have two choices - defend
yourself against people who can't stand the idea that someone
actually posts a correction, or accept that no matter what you say
there will always be bozos to argue with you, and let it go, saving
your energy for *useful* discussions.

The latter strategy is a *huge* timesaver, as I have discovered.


aye
 
C

Chris McDonald

Richard said:
If it was massive how come I never heard of it before? I dont doubt
there might be some. In the same way there is some about integers abd
bit places. Someone will always be confused.


Richard, you may be a liberal thinker, but you'll have to admit that the
grandiosity of your statements circles around your focus on the word
'massive'. A misunderstanding amongst students in Australia would be
very unlikely to be noticed by you, wherever. That does not exclude
the presence of any confusion, and it being seen by successive cohorts
of students. Common, frequent, regular.

I've carefully avoided any suggestion that you're using 'massive' as a
weasel word.
 
J

jackassplus

It is indeed quite common for people to refer to libraries
by referring to the header.  It is wrong to do so.  It is
extremely common for people to be so totally ignorant of
how libraries work and to indeed believe that the header
is the library.  How many times have you heard someone
complain "my program won't compile and it complains
about 'undefined function: log', but I included
math.h"?  I've lost count of the number of times
I've had to explain it, and I would prefer that more
people understand the very simple idea that the
header is not the library.  Too many people confuse
the two.  I believe that jackassp does not understand
the distinction.  Perhaps I am wrong about that.
You are correct. I've only made it through chapter 4 of K&R 2ed. I
thought I was being helpful. This is how we learn.
 
P

Paul Hsieh

I have been working on BASH shell programming a while and am very
pleased with its functionality to process text/string. Now I wonder if
there are any open source C or C++ libraries which can do the similar
things? E.g. regular expression support, cut/grep/sed functions, etc.

I know some are not actually BASH functions like " cut/grep/sed", but
it is really a pain to work out every such function by myself. I think
such thing should be in place already, but a simple google search does
not return any. May be it is hidden somewhere?

If you will excuse the self-plug, I would recommend a combination of
"The Better String Libary" and PCRE. You can access each via:

http://bstring.sf.net/
http://www.pcre.org/

PCRE will give you the same functionality of grep, but to manage
strings themselves you will be very well served by my library (The
Better String Library) and for the logic that cut, awk and sed can
perform the C programming language will give you sufficient glue to
easily give you the same level of programming power as what you have
grown accustomed to.

If you try to use just the built-in string functionality of the C
language you will have the following problems: 1) you will have to
design, implement and manage storage space for all strings you
manipulate (C supports finite fixed memory chunks in various forms)
and 2) you will have to reproduce the semantics of sophisticated
string matching algorithms that regular expression libraries do.

The first is nullified by my library, and the second is nullified by
PCRE. My library maintains C-string compatibility semantics, and PCRE
functions on C-strings, so the two libraries can be used together will
no serious issues.
 
J

jackassplus

Thank you for clarifying that.  I hope that the brevity of
my response to you did not offend you, in the sense that
you might consider that I was insulting your intelligence,
as that was certainly not my intent.


No offense taken.
I know almost enough to understand how little I know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top