bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: About po_header_field


From: Bruno Haible
Subject: Re: About po_header_field
Date: Tue, 27 May 2008 02:11:05 +0200
User-agent: KMail/1.5.4

Hello,

Nacho wrote:
> I think i found a bug in the po_header_field func.
> As you can in the po file attached in the Project-Id-Version field
> is missing the space between the ':' and the name of the project.
> For any reason if I try to get the project id version with po_header_field
> NULL is returned. If I add the space everything works fine.

Thank you for reporting this. The problem also appears in the msginit program
(in case a POT file has the same irregularity).

I'm applying this patch:

2008-05-26  Bruno Haible  <address@hidden>

        * gettext-po.c (po_header_field, po_header_set_field): Recognize a
        field also if there is no space after the ':'.
        Reported by Nacho <address@hidden>.

        * msginit.c (get_field, put_field): Recognize a field also if there is
        no space after the ':'.
        Reported by Nacho <address@hidden>.

Index: gettext-tools/src/msginit.c
===================================================================
RCS file: /sources/gettext/gettext/gettext-tools/src/msginit.c,v
retrieving revision 1.62
diff -c -3 -r1.62 msginit.c
*** gettext-tools/src/msginit.c 26 Apr 2008 00:12:10 -0000      1.62
--- gettext-tools/src/msginit.c 27 May 2008 00:04:39 -0000
***************
*** 1323,1336 ****
  
    for (line = header;;)
      {
!       if (strncmp (line, field, len) == 0
!         && line[len] == ':' && line[len + 1] == ' ')
        {
          const char *value_start;
          const char *value_end;
          char *value;
  
!         value_start = line + len + 2;
          value_end = strchr (value_start, '\n');
          if (value_end == NULL)
            value_end = value_start + strlen (value_start);
--- 1323,1337 ----
  
    for (line = header;;)
      {
!       if (strncmp (line, field, len) == 0 && line[len] == ':')
        {
          const char *value_start;
          const char *value_end;
          char *value;
  
!         value_start = line + len + 1;
!         if (*value_start == ' ')
!           value_start++;
          value_end = strchr (value_start, '\n');
          if (value_end == NULL)
            value_end = value_start + strlen (value_start);
***************
*** 1363,1375 ****
  
    for (line = old_header;;)
      {
!       if (strncmp (line, field, len) == 0
!         && line[len] == ':' && line[len + 1] == ' ')
        {
          const char *value_start;
          const char *value_end;
  
!         value_start = line + len + 2;
          value_end = strchr (value_start, '\n');
          if (value_end == NULL)
            value_end = value_start + strlen (value_start);
--- 1364,1377 ----
  
    for (line = old_header;;)
      {
!       if (strncmp (line, field, len) == 0 && line[len] == ':')
        {
          const char *value_start;
          const char *value_end;
  
!         value_start = line + len + 1;
!         if (*value_start == ' ')
!           value_start++;
          value_end = strchr (value_start, '\n');
          if (value_end == NULL)
            value_end = value_start + strlen (value_start);
Index: gettext-tools/libgettextpo/gettext-po.c
===================================================================
RCS file: /sources/gettext/gettext/gettext-tools/libgettextpo/gettext-po.c,v
retrieving revision 1.8
diff -c -3 -r1.8 gettext-po.c
*** gettext-tools/libgettextpo/gettext-po.c     21 Oct 2007 15:15:35 -0000      
1.8
--- gettext-tools/libgettextpo/gettext-po.c     27 May 2008 00:04:40 -0000
***************
*** 1,5 ****
  /* Public API for GNU gettext PO files.
!    Copyright (C) 2003-2007 Free Software Foundation, Inc.
     Written by Bruno Haible <address@hidden>, 2003.
  
     This program is free software: you can redistribute it and/or modify
--- 1,5 ----
  /* Public API for GNU gettext PO files.
!    Copyright (C) 2003-2008 Free Software Foundation, Inc.
     Written by Bruno Haible <address@hidden>, 2003.
  
     This program is free software: you can redistribute it and/or modify
***************
*** 341,354 ****
  
    for (line = header;;)
      {
!       if (strncmp (line, field, field_len) == 0
!         && line[field_len] == ':' && line[field_len + 1] == ' ')
        {
          const char *value_start;
          const char *value_end;
          char *value;
  
!         value_start = line + field_len + 2;
          value_end = strchr (value_start, '\n');
          if (value_end == NULL)
            value_end = value_start + strlen (value_start);
--- 341,355 ----
  
    for (line = header;;)
      {
!       if (strncmp (line, field, field_len) == 0 && line[field_len] == ':')
        {
          const char *value_start;
          const char *value_end;
          char *value;
  
!         value_start = line + field_len + 1;
!         if (*value_start == ' ')
!           value_start++;
          value_end = strchr (value_start, '\n');
          if (value_end == NULL)
            value_end = value_start + strlen (value_start);
***************
*** 387,394 ****
  
      for (line = header;;)
        {
!       if (strncmp (line, field, field_len) == 0
!           && line[field_len] == ':' && line[field_len + 1] == ' ')
          {
            const char *oldvalue_start;
            const char *oldvalue_end;
--- 388,394 ----
  
      for (line = header;;)
        {
!       if (strncmp (line, field, field_len) == 0 && line[field_len] == ':')
          {
            const char *oldvalue_start;
            const char *oldvalue_end;
***************
*** 398,404 ****
            size_t result_len;
            char *result;
  
!           oldvalue_start = line + field_len + 2;
            oldvalue_end = strchr (oldvalue_start, '\n');
            if (oldvalue_end == NULL)
              oldvalue_end = oldvalue_start + strlen (oldvalue_start);
--- 398,406 ----
            size_t result_len;
            char *result;
  
!           oldvalue_start = line + field_len + 1;
!           if (*oldvalue_start == ' ')
!             oldvalue_start++;
            oldvalue_end = strchr (oldvalue_start, '\n');
            if (oldvalue_end == NULL)
              oldvalue_end = oldvalue_start + strlen (oldvalue_start);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]