From: Bruno Haible Date: Wed, 30 Jan 2002 13:50:38 +0000 (+0000) Subject: Small cleanup for memory management. X-Git-Tag: v0.11~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6552f4c06ad9400205f4c5391874fac72938881;p=thirdparty%2Fgettext.git Small cleanup for memory management. --- diff --git a/src/ChangeLog b/src/ChangeLog index b224daec5..40b6d647b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2002-01-27 Bruno Haible + + * x-ycp.c (enum token_type_ty): New enum value token_type_symbol. + (x_ycp_lex): Assign a value to tp->string if and only if the type is + token_type_string_literal or token_type_symbol. + (extract_ycp): Simplify cleanup. + 2002-01-27 Bruno Haible * x-java.l (extract_java): Don't create a plural message if the diff --git a/src/x-ycp.c b/src/x-ycp.c index 7fb0088db..fbc4f0dbe 100644 --- a/src/x-ycp.c +++ b/src/x-ycp.c @@ -1,5 +1,5 @@ /* xgettext YCP backend. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001-2002 Free Software Foundation, Inc. This file was written by Bruno Haible , 2001. @@ -50,7 +50,8 @@ enum token_type_ty token_type_comma, /* , */ token_type_i18n, /* _( */ token_type_string_literal, /* "abc" */ - token_type_other /* number, symbol, misc. operator */ + token_type_symbol, /* symbol, number */ + token_type_other /* misc. operator */ }; typedef enum token_type_ty token_type_ty; @@ -58,7 +59,7 @@ typedef struct token_ty token_ty; struct token_ty { token_type_ty type; - char *string; + char *string; /* for token_type_string_literal, token_type_symbol */ int line_number; }; @@ -389,7 +390,6 @@ x_ycp_lex (tp) int bufpos; int c; - tp->string = NULL; for (;;) { tp->line_number = line_number; @@ -474,7 +474,7 @@ x_ycp_lex (tp) } buffer[bufpos] = '\0'; tp->string = xstrdup (buffer); - tp->type = token_type_other; + tp->type = token_type_symbol; return; case '"': @@ -606,9 +606,10 @@ extract_ycp (f, real_filename, logical_filename, mdlp) case token_type_eof: break; + case token_type_symbol: + free (token.string); + /* FALLTHROUGH */ default: - if (token.string != NULL) - free (token.string); state = 0; continue; }