Changes

Jump to: navigation, search

User:Minooz/OSD600/FF/patch565031

132 bytes added, 21:33, 20 April 2011
no edit summary
<div id="Apr16">
=== Apr16 ===
: The review of the bug suggests to start over the function based on the HTML5 specs.
: However, the spec is using an integer list to add the valid values dynamically. There are memory allocation problems with that in c++.
: Seems the existing method is more reasonable for doing the same concept but not following exact same steps.
: Also I'm not sure how using aSpec of type nsAString is doable instead of converting it using ''ToNewCString(aSpec)''
: So, still working on these issues...
<source lang="java">
void Area::ParseCoords(const nsAString& aSpec)
{
char* cp = ToNewCString(aSpec);
if (!&aSpeccp) {
return;
}
char *tptr;
char *n_str;
PRInt32 i, cnt, pos, value;
PRInt32 *value_list;
PRBool negated = false;
mCoords = nsnull;
/* * Skip beginning whitespace, all whitespace is empty list. */ n_str value_list = cpnew int [5]; while (is_separator(*n_str)) { n_str++; } if (*n_str == '\0') { return; }
/*
*/
cnt = 0;
value = 0;
n_str = cp;
while (*n_str != '\0')
{
tptr while (is_separator(*n_str)) { n_str++; value = 0; negated = false; started = false; gotNumber = false; finished = false; bogus = false; } if (*n_str== '\0') { break; } if (*n_str == '-')
{
if (gotNumber)
{
finished = true;
break;
}
if (started!finished) negated = false; else
{
if (started) negated = false; else { if (!bogus) negated = true; } }
started = true;
tptr++; cntn_str++;
}
else if (*n_str >= '0' && *n_str <= '9')
{
if (!finished) { breakvalue *= 10; *tptr value += *tptr * 10n_str - '0'; started = true; gotNumber = true; tptr n_str++; } if (is_separator(*n_str)) { if (!gotNumber) { break; } if (negated) { value *= -1; } value_list[cnt] = value; cnt++; }
}
else if (is_separator(*n_str))
{
if (!gotNumber) break; if (!negatedfinished) *tptr += *tptr; } else { } } /* * count the last entry in the list. */ cnt++;  /* * Allocate space for the coordinate array. */ value_list negated = new nscoord[cnt]false; if (!value_list) { return; }  /* * Second pass to copy integer values into list. */ tptr bogus = cptrue; for (i=0; i<cnt; i++) { char *ptr;  ptr = strchr(tptr, ','); if (ptrstarted) { *ptr = '\0' break; } /* * 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;
}
}
NS_Free(cp);
}
</source></div>
------
1
edit

Navigation menu