Difference between revisions of "User:Minooz/OSD600/FF/patch565031"

From CDOT Wiki
< User:Minooz‎ | OSD600‎ | FF
Jump to: navigation, search
(Apr16)
Line 2: Line 2:
 
=== Apr16 ===
 
=== Apr16 ===
 
<source lang="java">
 
<source lang="java">
 +
void Area::ParseCoords(const nsAString& aSpec)
 +
{
 +
  char* cp = ToNewCString(aSpec);
 +
  if (!&aSpec) {
 +
    return;
 +
  }
 +
    char *tptr;
 +
    char *n_str;
 +
    PRInt32 i, cnt;
 +
    PRInt32 *value_list;
 +
    PRBool negated = false;
 +
    PRBool started = false;
 +
    PRBool gotNumber = false;
 +
    PRBool finished = false;
 +
    PRBool bogus = false;
 +
 +
    /*
 +
    * Nothing in an empty list
 +
    */
 +
    mNumCoords = 0;
 +
    mCoords = nsnull;
 +
 +
    /*
 +
    * Skip beginning whitespace, all whitespace is empty list.
 +
    */
 +
    n_str = cp;
 +
    while (is_separator(*n_str))
 +
    {
 +
      n_str++;
 +
    }
 +
    if (*n_str == '\0')
 +
    {
 +
      return;
 +
    }
 +
 +
    /*
 +
    * Make a pass where any two numbers separated by just whitespace
 +
    * are given a comma separator.  Count entries while passing.
 +
    */
 +
    cnt = 0;
 +
    while (*n_str != '\0')
 +
    {
 +
      tptr = n_str;
 +
      if (*n_str == '-')
 +
      {
 +
        if (gotNumber)
 +
        {
 +
          finished = true;
 +
          break;
 +
        }
 +
        if (started)
 +
          negated = false;
 +
        else
 +
        {
 +
          if (!bogus)
 +
            negated = true;
 +
        }
 +
        started = true;
 +
        tptr++;
 +
        cnt++;
 +
      }
 +
      else if (*n_str >= '0' && *n_str <= '9')
 +
      {
 +
        if (finished)
 +
          break;
 +
        *tptr += *tptr * 10;
 +
        started = gotNumber = true;
 +
        tptr++;
 +
        cnt++;
 +
      }
 +
      else if (is_separator(*n_str))
 +
      {
 +
        if (!gotNumber)
 +
          break;
 +
        if (!negated)
 +
        *tptr += *tptr;
 +
     
 +
      }
 +
      else
 +
      {
 +
      }
 +
   
 +
    }
 +
    /*
 +
    * count the last entry in the list.
 +
    */
 +
    cnt++;
 +
 +
    /*
 +
    * Allocate space for the coordinate array.
 +
    */
 +
    value_list = new nscoord[cnt];
 +
    if (!value_list)
 +
    {
 +
      return;
 +
    }
 +
 +
    /*
 +
    * Second pass to copy integer values into list.
 +
    */
 +
    tptr = cp;
 +
    for (i=0; i<cnt; i++)
 +
    {
 +
      char *ptr;
 +
 +
      ptr = strchr(tptr, ',');
 +
      if (ptr)
 +
      {
 +
        *ptr = '\0';
 +
      }
 +
      /*
 +
      * Strip whitespace in front of number because I don't
 +
      * trust atoi to do it on all platforms.
 +
      */
 +
      while (*tptr == ' ')
 +
      {
 +
        tptr++;
 +
      }
 +
      if (*tptr == '\0')
 +
      {
 +
        value_list[i] = 0;
 +
      }
 +
      else
 +
      {
 +
        value_list[i] = (nscoord) ::atoi(tptr);
 +
      }
 +
      if (ptr)
 +
      {
 +
        *ptr = ',';
 +
        tptr = ptr + 1;
 +
      }
 +
    }
 +
 +
    mNumCoords = cnt;
 +
    mCoords = value_list;
 +
 +
    NS_Free(cp);
 
</source></div>
 
</source></div>
 
------
 
------
 
<div id="Apr6">
 
<div id="Apr6">
 +
 
=== Apr6 ===
 
=== Apr6 ===
 
<source lang="java">
 
<source lang="java">

Revision as of 15:54, 17 April 2011

Apr16

void Area::ParseCoords(const nsAString& aSpec)
{
  char* cp = ToNewCString(aSpec);
  if (!&aSpec) {
    return;
  }
    char *tptr;
    char *n_str;
    PRInt32 i, cnt;
    PRInt32 *value_list;
    PRBool negated = false;
    PRBool started = false;
    PRBool gotNumber = false;
    PRBool finished = false;
    PRBool bogus = false;

    /*
     * Nothing in an empty list
     */
    mNumCoords = 0;
    mCoords = nsnull;

    /*
     * Skip beginning whitespace, all whitespace is empty list.
     */
    n_str = cp;
    while (is_separator(*n_str))
    {
      n_str++;
    }
    if (*n_str == '\0')
    {
      return;
    }

    /*
     * Make a pass where any two numbers separated by just whitespace
     * are given a comma separator.  Count entries while passing.
     */
    cnt = 0;
    while (*n_str != '\0')
    {
      tptr = n_str;
      if (*n_str == '-')
      {
        if (gotNumber)
        {
          finished = true;
          break;
        }
        if (started)
          negated = false;
        else
        {
          if (!bogus)
            negated = true;
        }
        started = true;
        tptr++;
        cnt++;
      }
      else if (*n_str >= '0' && *n_str <= '9')
      {
        if (finished)
          break;
        *tptr += *tptr * 10;
        started = gotNumber = true;
        tptr++;
        cnt++;
      }
      else if (is_separator(*n_str))
      {
        if (!gotNumber)
          break;
        if (!negated)
        *tptr += *tptr;
       
      }
      else
      {
      }
     
    }
    /*
     * count the last entry in the list.
     */
    cnt++;

    /*
     * Allocate space for the coordinate array.
     */
    value_list = new nscoord[cnt];
    if (!value_list)
    {
      return;
    }

    /*
     * Second pass to copy integer values into list.
     */
    tptr = cp;
    for (i=0; i<cnt; i++)
    {
      char *ptr;

      ptr = strchr(tptr, ',');
      if (ptr)
      {
        *ptr = '\0';
      }
      /*
       * Strip whitespace in front of number because I don't
       * trust atoi to do it on all platforms.
       */
      while (*tptr == ' ')
      {
        tptr++;
      }
      if (*tptr == '\0')
      {
        value_list[i] = 0;
      }
      else
      {
        value_list[i] = (nscoord) ::atoi(tptr);
      }
      if (ptr)
      {
        *ptr = ',';
        tptr = ptr + 1;
      }
    }

    mNumCoords = cnt;
    mCoords = value_list;

    NS_Free(cp);

Apr6

// Modified based on Matt Postil's Version
diff -r e6b318aca788 layout/generic/nsImageMap.cpp
--- a/layout/generic/nsImageMap.cpp	Wed Apr 06 17:38:21 2011 -0700
+++ b/layout/generic/nsImageMap.cpp	Sat Apr 09 20:50:51 2011 -0400
@@ -112,12 +112,7 @@
 inline PRBool
 is_space(char c)
 {
-  return (c == ' ' ||
-          c == '\f' ||
-          c == '\n' ||
-          c == '\r' ||
-          c == '\t' ||
-          c == '\v');
+  return c == ' ';
 }
 
 static void logMessage(nsIContent*      aContent,
@@ -186,12 +181,17 @@
        * Skip to a separator
        */
       tptr = n_str;
-      while (!is_space(*tptr) && *tptr != ',' && *tptr != '\0')
+      while (!is_space(*tptr) && *tptr != ',' &&  *tptr != ';' && *tptr != '\0')
       {
         tptr++;
       }
       n_str = tptr;
 
       /*
        * If no more entries, break out here
        */
@@ -205,7 +205,7 @@
        * comma.
        */
       has_comma = PR_FALSE;
-      while (is_space(*tptr) || *tptr == ',')
+      while (is_space(*tptr) || *tptr == ',' || *tptr == ';')
       {
         if (*tptr == ',')
         {