]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Small cleanup for memory management.
authorBruno Haible <bruno@clisp.org>
Wed, 30 Jan 2002 13:50:38 +0000 (13:50 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 23:10:51 +0000 (01:10 +0200)
src/ChangeLog
src/x-ycp.c

index b224daec58e1420460c5810cd51e99ae8e0270ef..40b6d647b129b5a70c2553af63853b16c546d541 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-27  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        * x-java.l (extract_java): Don't create a plural message if the
index 7fb0088dbf933e4e10fe0faa16943d8591b3583b..fbc4f0dbe270c21c8e763d87e4fbe06474e46ed8 100644 (file)
@@ -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 <haible@clisp.cons.org>, 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;
        }