+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
+Tue Oct 27 07:25:53 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ * gscanner.c:
+ (g_scanner_sync_file_offset): new function for file input.
+ rewind the filedescriptor to the current buffer position and blow
+ the file read ahead buffer. usefull for third party uses of our
+ filedescriptor, which hooks onto the current scanning position.
+ (this became neccessary with the implementation of buffered
+ reads).
+ (g_scanner_input_file):
+ (g_scanner_input_text): automatically blow the read ahead buffer.
+ (g_scanner_get_char): blow the read ahead buffer when the end of
+ input is reached, i.e. a '\000' char is read.
+
Tue Oct 27 00:27:31 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: get rid of duplicate #g_htonl and friends in the
void g_scanner_destroy (GScanner *scanner);
void g_scanner_input_file (GScanner *scanner,
gint input_fd);
+void g_scanner_sync_file_offset (GScanner *scanner);
void g_scanner_input_text (GScanner *scanner,
const gchar *text,
guint text_len);
void g_scanner_destroy (GScanner *scanner);
void g_scanner_input_file (GScanner *scanner,
gint input_fd);
+void g_scanner_sync_file_offset (GScanner *scanner);
void g_scanner_input_text (GScanner *scanner,
const gchar *text,
guint text_len);
g_return_if_fail (scanner != NULL);
g_return_if_fail (input_fd >= 0);
+ if (scanner->input_fd >= 0)
+ g_scanner_sync_file_offset (scanner);
+
scanner->token = G_TOKEN_NONE;
scanner->value.v_int = 0;
scanner->line = 1;
else
text = NULL;
+ if (scanner->input_fd >= 0)
+ g_scanner_sync_file_offset (scanner);
+
scanner->token = G_TOKEN_NONE;
scanner->value.v_int = 0;
scanner->line = 1;
return 0;
}
+void
+g_scanner_sync_file_offset (GScanner *scanner)
+{
+ g_return_if_fail (scanner != NULL);
+
+ /* for file input, rewind the filedescriptor to the current
+ * buffer position and blow the file read ahead buffer. usefull for
+ * third party uses of our filedescriptor, which hooks onto the current
+ * scanning position.
+ */
+
+ if (scanner->input_fd >= 0 && scanner->text_end > scanner->text)
+ {
+ gint buffered;
+
+ buffered = scanner->text_end - scanner->text;
+ if (lseek (scanner->input_fd, - buffered, SEEK_CUR) >= 0)
+ {
+ /* we succeeded, blow our buffer's contents now */
+ scanner->text = NULL;
+ scanner->text_end = NULL;
+ }
+ else
+ errno = 0;
+ }
+}
+
static guchar
g_scanner_get_char (GScanner *scanner,
guint *line_p,
scanner->text = buffer + 1;
scanner->text_end = buffer + count;
fchar = *buffer;
+ if (!fchar)
+ {
+ g_scanner_sync_file_offset (scanner);
+ scanner->text_end = scanner->text;
+ scanner->input_fd = -1;
+ }
}
}
else
g_return_if_fail (scanner != NULL);
g_return_if_fail (input_fd >= 0);
+ if (scanner->input_fd >= 0)
+ g_scanner_sync_file_offset (scanner);
+
scanner->token = G_TOKEN_NONE;
scanner->value.v_int = 0;
scanner->line = 1;
else
text = NULL;
+ if (scanner->input_fd >= 0)
+ g_scanner_sync_file_offset (scanner);
+
scanner->token = G_TOKEN_NONE;
scanner->value.v_int = 0;
scanner->line = 1;
return 0;
}
+void
+g_scanner_sync_file_offset (GScanner *scanner)
+{
+ g_return_if_fail (scanner != NULL);
+
+ /* for file input, rewind the filedescriptor to the current
+ * buffer position and blow the file read ahead buffer. usefull for
+ * third party uses of our filedescriptor, which hooks onto the current
+ * scanning position.
+ */
+
+ if (scanner->input_fd >= 0 && scanner->text_end > scanner->text)
+ {
+ gint buffered;
+
+ buffered = scanner->text_end - scanner->text;
+ if (lseek (scanner->input_fd, - buffered, SEEK_CUR) >= 0)
+ {
+ /* we succeeded, blow our buffer's contents now */
+ scanner->text = NULL;
+ scanner->text_end = NULL;
+ }
+ else
+ errno = 0;
+ }
+}
+
static guchar
g_scanner_get_char (GScanner *scanner,
guint *line_p,
scanner->text = buffer + 1;
scanner->text_end = buffer + count;
fchar = *buffer;
+ if (!fchar)
+ {
+ g_scanner_sync_file_offset (scanner);
+ scanner->text_end = scanner->text;
+ scanner->input_fd = -1;
+ }
}
}
else