Ejemplo n.º 1
0
/* Tag will be of a few defined forms:
   ^[:alpha:]*=".*"$
   ^[:alpha:]*=.*$

   <invalid tag>

So we must determine end of tag name, start of value, end of value.
*/
static void gpspoint_process_tag ( const gchar *tag, guint len )
{
  const gchar *key_end, *value_start, *value_end;

  /* Searching for key end */
  key_end = tag;

  while (++key_end - tag < len)
    if (*key_end == '=')
      break;

  if (key_end - tag == len)
    return; /* no good */

  if (key_end - tag == len + 1)
    value_start = value_end = 0; /* size = 0 */
  else
  {
    value_start = key_end + 1; /* equal_sign plus one */

    if (*value_start == '"')
    {
      value_start++;
      if (*value_start == '"')
        value_start = value_end = 0; /* size = 0 */
      else
      {
        if (*(tag+len-1) == '"')
          value_end = tag + len - 1;
        else
          return; /* bogus */
      }
    }
    else
      value_end = tag + len; /* value start really IS value start. */

    // Detect broken lines which end without any text or the enclosing ". i.e. like: comment="
    if ( (value_end - value_start) < 0 )
      return;

    gpspoint_process_key_and_value(tag, key_end - tag, value_start, value_end - value_start);
  }
}
Ejemplo n.º 2
0
/* Tag will be of a few defined forms:
   ^[:alpha:]*=".*"$
   ^[:alpha:]*=.*$

   <invalid tag>

So we must determine end of tag name, start of value, end of value.
*/
static void gpspoint_process_tag ( const gchar *tag, gint len )
{
    const gchar *key_end, *value_start, *value_end;

    /* Searching for key end */
    key_end = tag;

    while (++key_end - tag < len)
        if (*key_end == '=')
            break;

    if (key_end - tag == len)
        return; /* no good */

    if (key_end - tag == len + 1)
        value_start = value_end = 0; /* size = 0 */
    else
    {
        value_start = key_end + 1; /* equal_sign plus one */

        if (*value_start == '"')
        {
            value_start++;
            if (*value_start == '"')
                value_start = value_end = 0; /* size = 0 */
            else
            {
                if (*(tag+len-1) == '"')
                    value_end = tag + len - 1;
                else
                    return; /* bogus */
            }
        }
        else
            value_end = tag + len; /* value start really IS value start. */

        gpspoint_process_key_and_value(tag, key_end - tag, value_start, value_end - value_start);
    }
}