diff options
author | Dodji Seketeli <dodji@src.gnome.org> | 2003-04-21 18:05:14 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2003-04-21 18:05:14 +0000 |
commit | f18a6bed7d5f6e1ed5bde510a58efad6308daf7e (patch) | |
tree | 9d6dd6f56247f2eed81ffcd5fd46a24d4567fb26 | |
parent | c3728eba9873805b8e259b6f1a567c9d7697e566 (diff) | |
download | libcroco-f18a6bed7d5f6e1ed5bde510a58efad6308daf7e.tar.gz |
*Doxyfile: fixed a small bug due to the new source tree layout.
*src/parser/cr-input.c, src/parser/cr-token.c: killed a memleak .
Dodji
-rw-r--r-- | Doxyfile | 2 | ||||
-rw-r--r-- | src/layeng/cr-box-view.h | 61 | ||||
-rw-r--r-- | src/parser/cr-input.c | 176 | ||||
-rw-r--r-- | src/parser/cr-token.c | 70 | ||||
-rwxr-xr-x | tests/vg | 2 |
5 files changed, 107 insertions, 204 deletions
@@ -316,7 +316,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = src +INPUT = src src/parser src/seleng src/layeng # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/src/layeng/cr-box-view.h b/src/layeng/cr-box-view.h new file mode 100644 index 0000000..ddbb3f4 --- /dev/null +++ b/src/layeng/cr-box-view.h @@ -0,0 +1,61 @@ +/* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */ + +/* + * This file is part of The Croco Library + * + * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2.1 of + * the GNU Lesser General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the + * GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +/* + *$Id$ + */ +#ifndef __CR_BOX_VIEW__ +#define __CR_BOX_VIEW__ + + +#include <gnome.h> +#include <cr-box.h>/*the box model*/ + +G_BEGIN_DECLS + +#define CR_TYPE_BOX_VIEW (cr_box_view_get_type ()) +#define CR_BOX_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CR_TYPE_BOX_VIEW, GtkLayout)) +#define CR_BOX_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CR_TYPE_BOX_VIEW, GtkLayoutClass)) +#define CR_IS_BOX_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CR_TYPE_BOX_VIEW)) +#define CR_IS_BOX_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CR_TYPE_BOX_VIEW)) +#define CR_BOX_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CR_TYPE_BOX_VIEW, GtkLayoutClass)) + +typedef struct _CRBoxView CRBoxView ; +typedef struct _CRBoxViewClass CRBoxViewClass ; + +struct _CRBoxView +{ + GtkLayout view ; + CRBox *box ; +} ; + +struct _CRBoxViewClass +{ + GtkLayoutClass parent_class ; + +} ; + +G_END_DECLS + +#endif diff --git a/src/parser/cr-input.c b/src/parser/cr-input.c index aeba09b..1c6bc76 100644 --- a/src/parser/cr-input.c +++ b/src/parser/cr-input.c @@ -114,8 +114,9 @@ cr_input_new_real (void) cr_utils_trace_info ("Out of memory") ; g_free (result) ; return NULL ; - } + } memset (PRIVATE (result), 0, sizeof (CRInputPriv)) ; + PRIVATE (result)->free_in_buf = TRUE ; return result ; } @@ -176,6 +177,8 @@ cr_input_new_from_buf (guchar *a_buf, gulong a_len, PRIVATE (result)->nb_bytes = a_len ; } + PRIVATE (result)->free_in_buf = a_free_buf ; + return result ; error: @@ -199,8 +202,7 @@ cr_input_new_from_buf (guchar *a_buf, gulong a_len, *this method couldn read the file and create it, *NULL otherwise. */ -#define NEW0 = 1 -#ifdef NEW0 + CRInput * cr_input_new_from_uri (gchar *a_file_uri, enum CREncoding a_enc) { @@ -249,7 +251,7 @@ cr_input_new_from_uri (gchar *a_file_uri, enum CREncoding a_enc) cr_utils_trace_debug ("an io error occured") ; status = CR_ERROR ; - goto error ; + goto cleanup ; } } @@ -264,11 +266,6 @@ cr_input_new_from_uri (gchar *a_file_uri, enum CREncoding a_enc) } } - if (file_ptr) - { - fclose (file_ptr) ; - file_ptr = NULL ; - } if (status == CR_OK) { @@ -276,12 +273,11 @@ cr_input_new_from_uri (gchar *a_file_uri, enum CREncoding a_enc) TRUE) ; if (!result) { - goto error ; - } - return result ; + goto cleanup ; + } } - error: +cleanup: if (file_ptr) { @@ -295,162 +291,8 @@ cr_input_new_from_uri (gchar *a_file_uri, enum CREncoding a_enc) buf = NULL ; } - return NULL ; -} -#else -CRInput * -cr_input_new_from_uri (gchar *a_file_uri, enum CREncoding a_enc) -{ - CRInput * result = NULL ; - enum CRStatus status = CR_OK ; - FILE * file_ptr = NULL ; - guchar tmp_buf[CR_INPUT_MEM_CHUNK_SIZE] = {0} ; - gint nb_read = 0 ; - gboolean loop = TRUE ; - CREncHandler * enc_handler = NULL ; - guchar *utf8_buf = NULL ; - gulong len = 0 ; - - g_return_val_if_fail (a_file_uri, NULL) ; - - file_ptr = fopen (a_file_uri, "r") ; - - if (file_ptr == NULL) - { - -#ifdef CR_DEBUG - cr_utils_trace_debug ("could not open file") ; -#endif - g_warning ("Could not open file %s\n", a_file_uri) ; - - return NULL ; - } - - result = g_try_malloc (sizeof (CRInput)) ; - if (!result) - { - cr_utils_trace_info ("Out of memory") ; - return NULL ; - } - memset (result, 0, sizeof (CRInput)) ; - - PRIVATE (result) = g_try_malloc (sizeof (CRInputPriv)) ; - if (!PRIVATE (result)) - { - cr_utils_trace_info ("Out of memory") ; - g_free (result) ; - return NULL ; - } - memset (PRIVATE (result), 0, sizeof (CRInputPriv)) ; - - /*load the file*/ - while (loop) - { - - nb_read = - fread (tmp_buf, 1/*read bytes*/, - CR_INPUT_MEM_CHUNK_SIZE/*nb of bytes*/, - file_ptr) ; - - if (nb_read != CR_INPUT_MEM_CHUNK_SIZE) - { - /*we read less chars than we wanted*/ - if (feof (file_ptr)) - { - /*we reached eof*/ - loop = FALSE ; - } - else - { - /*a pb occured !!*/ -#ifdef CR_DEBUG - cr_utils_trace_debug - ("an io error occured") ; -#endif - status = CR_ERROR ; - } - } - - if (status == CR_OK) - { - /*read went well*/ - - PRIVATE (result)->in_buf = - g_realloc (PRIVATE (result)->in_buf, - PRIVATE (result)->in_buf_size - + CR_INPUT_MEM_CHUNK_SIZE) ; - - memcpy (PRIVATE (result)->in_buf - + PRIVATE (result)->in_buf_size , - tmp_buf, nb_read) ; - - PRIVATE (result)->in_buf_size += - nb_read ; - } - } - - PRIVATE (result)->nb_bytes = PRIVATE (result)->in_buf_size ; - - if (file_ptr) - { - fclose (file_ptr) ; - file_ptr = NULL ; - } - - if (status == CR_OK) - { - /* - *Make sure the input's internal buffer - *is encoded in utf-8. - */ - if (a_enc != CR_UTF_8) - { - enc_handler = cr_enc_handler_get_instance (a_enc); - if (enc_handler == NULL) - { - goto error ; - } - else - { - /*encode the buffer in utf8.*/ - status = cr_enc_handler_convert_input - (enc_handler, - PRIVATE (result)->in_buf, - &PRIVATE (result)->in_buf_size, - &utf8_buf, &len) ; - - if (status != CR_OK) - { - goto error ; - } - - g_free (PRIVATE (result)->in_buf) ; - PRIVATE (result)->in_buf = utf8_buf ; - PRIVATE (result)->in_buf_size = len ; - PRIVATE (result)->line = 1 ; - } - } - } - else - { - cr_utils_trace_debug ("Input loading failed") ; - goto error ; - } - return result ; - - error: - if (result) - { - - /*free result*/ - cr_input_destroy (result) ; - result = NULL ; - } - - return NULL ; } -#endif /** *The destructor of the #CRInput class. diff --git a/src/parser/cr-token.c b/src/parser/cr-token.c index 2404d8d..8ade6be 100644 --- a/src/parser/cr-token.c +++ b/src/parser/cr-token.c @@ -53,55 +53,55 @@ cr_token_clear (CRToken *a_this) case MEDIA_SYM_TK: case FONT_FACE_SYM_TK: case CHARSET_SYM_TK: - case IMPORT_SYM_TK: + case IMPORT_SYM_TK: case IMPORTANT_SYM_TK: - break ; + break ; case STRING_TK: - case IDENT_TK: - case HASH_TK: - case URI_TK: - case FUNCTION_TK: - case COMMENT_TK: - if (a_this->u.str) - { - g_string_free (a_this->u.str, TRUE) ; - a_this->u.str = NULL ; - } + case IDENT_TK: + case HASH_TK: + case URI_TK: + case FUNCTION_TK: + case COMMENT_TK: + if (a_this->u.str) + { + g_string_free (a_this->u.str, TRUE) ; + a_this->u.str = NULL ; + } break ; case EMS_TK: - case EXS_TK: - case LENGTH_TK: - case ANGLE_TK: - case TIME_TK: - case FREQ_TK: - case PERCENTAGE_TK: - case NUMBER_TK: - if (a_this->u.num) - { - cr_num_destroy (a_this->u.num) ; - a_this->u.num = NULL ; - } + case EXS_TK: + case LENGTH_TK: + case ANGLE_TK: + case TIME_TK: + case FREQ_TK: + case PERCENTAGE_TK: + case NUMBER_TK: + if (a_this->u.num) + { + cr_num_destroy (a_this->u.num) ; + a_this->u.num = NULL ; + } break ; case DIMEN_TK: - if (a_this->u.num) - { - cr_num_destroy (a_this->u.num) ; - a_this->u.num = NULL ; - } + if (a_this->u.num) + { + cr_num_destroy (a_this->u.num) ; + a_this->u.num = NULL ; + } - if (a_this->dimen) - { - g_string_free (a_this->dimen, TRUE) ; - a_this->dimen = NULL ; - } + if (a_this->dimen) + { + g_string_free (a_this->dimen, TRUE) ; + a_this->dimen = NULL ; + } break ; case UNICODERANGE_TK: - /*not supported yet.*/ + /*not supported yet.*/ break ; default: @@ -21,4 +21,4 @@ if test "empty$1" != "empty" ; then OUTPUT_FILE="$1".vg fi -exec $VG $VG_OPTIONS $@ 2>$OUTPUT_FILE
\ No newline at end of file +exec $VG $VG_OPTIONS $@ 2>"$OUTPUT_FILE"
\ No newline at end of file |