Re: [gtk-list] GScanner::text, private??



On Fri, 7 Jan 2000, Manuel Estrada wrote:

> 
> 	Hi all,
> 
> 	I need to parse a text which has more information than I want,
> so I need to know were the scanner is reading to be able to start from
> there to do something else with the rest.
> 
> 	Now I use GScanner->text and it works, but it is suposed to be
> private :(
> 	Maybe there is some other "legal" way to find out or maybe
> GScanner could take some change, a new function or maybe "text" could
> be considered public. (I am willing to try coding the change if
> needed) 

i don't exactly understand what you do, do you use GScanner to skip
over a text untill you find a certain keyword/phrase and then read
the text from there with your own routines?
the problem with text is that it always contains a small chunk of the
source text only, so worst case is you just parsed "foo" of "foo bar baz"
and ->text actually only contains "foo ba" (not including trailing \0,
iirc).
gscanner will simply read in more text if it needs to, but for you
->text is basically non-reliable.

what you can do is calling g_scanner_sync_file_offset() after you parsed
"foo", and then read the rest text with read() from gscanner's input fd,
this function will reposition the file pointer to match exactly the position
gscanner is currently parsing at.
(you can also resume scanning at that position at a later point by lseek()ing
the file back to that position and continuing with gscanner as normal).

> 
> 	Thanks in advance
> 
> 		Ranty
> 
> PS: please answer directly, as I am not in the list.
> 

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]