Gary Kline wrote:
On Mon, Oct 19, 2009 at 11:09:19AM -0700, Patrick Mahan wrote:
See comments interspaced below -
Gary,
Let me restate your problem: You want to read through a file containing tags
delimited by "<>" and to skip these tags if the user has run your command
with
the "-N" flag.
In C any thing passed by address is "by reference". For a your static
buffer
of 1024 characters: you can pass it by reference as:
skiptags(buf); /* passes in the starting address of the buffer */
skiptags(&buf[0]); /* passes in the starting address of the
buffer */
skiptags(&buf[10]); /* passes int the starting address of the
buffer
at the 11th character position. */
Arrays and pointers are always by reference. Individual data types "int",
"char", etc are by value unless passed in as a pointer. I think this is
where
your confusion is around.
You've got it exactly right, Patrick. There were no "C" classes in 1978--I
taught myself. Obviously, not that well because I have already dreaded
pointers. ---Well, usually.
You are welcome, glad to help.
[examples snipped]
Your examples help a lot! Everything works except when there are two or more
tags on one line such as:
<BODY BGCOLOR="#FFFFFF" LINK="#00FFFF" VLINK="#006633"><FONT SIZE="4">
I think I see where is your skiptags--pointer arithematic
function--this can be
caught. Thanks much!
If I might make a suggestion. Make use of a case (switch) statement:
switch(buf[c]) {
case '<': /* start of tag, skip it if requested */
if (skiptags) c = skiptag(&buf[c]);
...
default: /* handle normal stuff */
...
}
Inside your while() statement.
Good luck,
Patrick
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"