Age | Commit message (Collapse) | Author |
|
Gcc 4.8 defines __cplusplus as 201103L, so we can check for that now. It
still also defines __GXX_EXPERIMENTAL_CXX0X__, but this could help on
other compilers, or if gcc ever decides to stop defining the
experimental macro.
|
|
When checking the `left` argument, it previously allowed having
left == len. However, this means the substring starts one past the last
character in the string and should return the empty string. In practice,
this already worked correctly, because buffer[len] contains the trailing
nul, so it would (re)assign the empty string to `out`.
However, fixing this check makes it a bit more logical, and prevents a
fairly unlikely out-of-buffer write (to address 0x0) when calling
substring on an invalidated String:
String bar = (char*)NULL;
bar.substring(0, 0);
|
|
Previously, this method calculated the length of the string from the
given index onwards. However, the other remove() method called already
contains code for this calculation, which is used when the count passed
in is too big. This means we can just pass in a very big count that is
guaranteed to point past the end of the string, shrinking the remove
method by a few bytes.
|
|
Previously, if you passed in a very big index and/or count, the
`index + count` could overflow, making the count be used as-is instead
of being truncated (causing the string to be updated wrongly and
potentially writing to arbitrary memory locations).
We can rewrite the comparison to use `len - index` instead. Since we
know that index < len, we are sure this subtraction does not overflow,
regardless of what values of index and count we pass in.
As an added bonus, the `len - index` value already needed be calculated
inside the if, so this saves a few instructions in the generated code.
To illustrate this problem, consider this code:
String foo = "foo";
Serial.println(foo.length()); // Prints 3
foo.remove(1, 65535); // Should remove all but first character
Serial.println(foo.length()); // Prints 4 without this patch
Not shown in this is example is that some arbitrary memory is written
as well.
|
|
This check already happens in the remove(unsigned int, unsigned int)
method that is caled, so there is no need to also check this here.
|
|
|
|
On later versions of avr-libc, prog_char is deprecated. In 0acebeeff48
the one occurence of prog_char was replaced by "char PROGMEM", which is
not entirely correct (PROGMEM is supposed to be an attribute on a
variable, not on a type, even though this is how things work in older
libc versions). However, in 1130fede3a2 a few new occurences of
prog_char are introduced, which break compilation on newer libc versions
again.
This commit changes all these pointer types to use the PGM_P macro from
<avr/pgmspace.h>. This macro is just "const char *" in newer libc
versions and "const prog_char *" in older versions, so it should always
work.
References #795
|
|
This should make explicit String-from-integer constructor working again:
int a = 10;
String(a, 4);
|
|
|
|
|
|
|
|
|
|
Merge branch 'master' into ide-1.5.x
|
|
|
|
Small code cleanup.
|
|
|
|
|
|
|
|
http://code.google.com/p/arduino/issues/detail?id=694
|
|
|
|
|
|
This makes explicit the String constructors that take numeric types and chars and removes the versions of concat() and operator=() and operator+() that accept numberic types.
It also replaces the operator bool() with a operator that converts to a function pointer. This allows for uses like "if (s)" but not "s + 123". See: http://www.artima.com/cppsource/safebool.html. This allowed removing the disambiguating operator+() functions and relying solely on StringSumHelper and anonymous temporaries once again.
Also, now treating unsigned char's like int when constructing Strings from them, i.e. String(byte(65)) is now "65" not "A". This is consistent with the new behavior of Serial.print(byte).
|
|
|
|
|
|
|
|
Which means you can't chain multiple concat() calls together, but you can check if they succeeded or not.
|
|
Changing toLowerCase(), toUpperCase(), trim() and replace() to return void instead of a reference to the string that's just been changed. That way, it's clear that the functions modify the string they've been called on.
|
|
|
|
We should probably add something like this back in later, but I want to do one thing at a time. This removes the __FlashStringHelper class as well.
|
|
http://www.pjrc.com/teensy/string_class_experimental.html
|
|
|
|
http://code.google.com/p/arduino/issues/detail?id=332
|
|
|
|
Adds toInt() to String, WCharacter.h (from Wiring), and an SD Datalogger example.
|
|
This reverts commit 448222e4b65e0cf44dfc0c494f7f76901f1fabea.
|
|
|
|
than return one. That way they don't expose the internal representation of the String class, allowing future optimization. Thanks to Paul Stoffregen.
|
|
length (in operator[]).
|
|
non-null buffer before modifying its contents).
|
|
more types.
|
|
|
|
|
|
|
|
|
|
WString.h from WProgram.h.
|
|
actually work yet.
|