Skip to content

Commit 1a4e885

Browse files
committed
Merge branch 'ide-1.5.x' into zero
1 parent b4bc89c commit 1a4e885

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

cores/arduino/Server.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
Copyright (c) 2014 Arduino. All right reserved.
2+
Server.h - Base class that provides Server
3+
Copyright (c) 2011 Adrian McEwen. All right reserved.
34
45
This library is free software; you can redistribute it and/or
56
modify it under the terms of the GNU Lesser General Public
@@ -8,8 +9,8 @@
89
910
This library is distributed in the hope that it will be useful,
1011
but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
See the GNU Lesser General Public License for more details.
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
1314
1415
You should have received a copy of the GNU Lesser General Public
1516
License along with this library; if not, write to the Free Software
@@ -19,6 +20,8 @@
1920
#ifndef server_h
2021
#define server_h
2122

23+
#include "Print.h"
24+
2225
class Server : public Print {
2326
public:
2427
virtual void begin() =0;

cores/arduino/WString.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/*
2-
Copyright (c) 2014 Arduino. All right reserved.
2+
WString.cpp - String library for Wiring & Arduino
3+
...mostly rewritten by Paul Stoffregen...
4+
Copyright (c) 2009-10 Hernando Barragan. All rights reserved.
5+
Copyright 2011, Paul Stoffregen, [email protected]
36
47
This library is free software; you can redistribute it and/or
58
modify it under the terms of the GNU Lesser General Public
@@ -8,8 +11,8 @@
811
912
This library is distributed in the hope that it will be useful,
1013
but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
See the GNU Lesser General Public License for more details.
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
1316
1417
You should have received a copy of the GNU Lesser General Public
1518
License along with this library; if not, write to the Free Software
@@ -213,10 +216,10 @@ void String::move(String &rhs)
213216
String & String::operator = (const String &rhs)
214217
{
215218
if (this == &rhs) return *this;
216-
219+
217220
if (rhs.buffer) copy(rhs.buffer, rhs.len);
218221
else invalidate();
219-
222+
220223
return *this;
221224
}
222225

@@ -238,7 +241,7 @@ String & String::operator = (const char *cstr)
238241
{
239242
if (cstr) copy(cstr, strlen(cstr));
240243
else invalidate();
241-
244+
242245
return *this;
243246
}
244247

@@ -481,7 +484,7 @@ unsigned char String::equalsIgnoreCase( const String &s2 ) const
481484
const char *p2 = s2.buffer;
482485
while (*p1) {
483486
if (tolower(*p1++) != tolower(*p2++)) return 0;
484-
}
487+
}
485488
return 1;
486489
}
487490

@@ -512,7 +515,7 @@ char String::charAt(unsigned int loc) const
512515
return operator[](loc);
513516
}
514517

515-
void String::setCharAt(unsigned int loc, char c)
518+
void String::setCharAt(unsigned int loc, char c)
516519
{
517520
if (loc < len) buffer[loc] = c;
518521
}
@@ -618,10 +621,10 @@ String String::substring(unsigned int left, unsigned int right) const
618621
left = temp;
619622
}
620623
String out;
621-
if (left > len) return out;
624+
if (left >= len) return out;
622625
if (right > len) right = len;
623626
char temp = buffer[right]; // save the replaced character
624-
buffer[right] = '\0';
627+
buffer[right] = '\0';
625628
out = buffer + left; // pointer arithmetic
626629
buffer[right] = temp; //restore character
627630
return out;
@@ -683,15 +686,16 @@ void String::replace(const String& find, const String& replace)
683686
}
684687

685688
void String::remove(unsigned int index){
686-
if (index >= len) { return; }
687-
int count = len - index;
688-
remove(index, count);
689+
// Pass the biggest integer as the count. The remove method
690+
// below will take care of truncating it at the end of the
691+
// string.
692+
remove(index, (unsigned int)-1);
689693
}
690694

691695
void String::remove(unsigned int index, unsigned int count){
692696
if (index >= len) { return; }
693697
if (count <= 0) { return; }
694-
if (index + count > len) { count = len - index; }
698+
if (count > len - index) { count = len - index; }
695699
char *writeTo = buffer + index;
696700
len = len - count;
697701
strncpy(writeTo, buffer + index + count,len - index);

variants/arduino_zero/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,21 @@ extern "C"
5757

5858
#define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) )
5959
#define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin )
60-
#define digitalPinToTimer(P) ( )
6160
//#define analogInPinToBit(P) ( )
6261
#define portOutputRegister(port) ( &(port->OUT.reg) )
6362
#define portInputRegister(port) ( &(port->IN.reg) )
6463
#define portModeRegister(port) ( &(port->DIR.reg) )
6564
#define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER )
6665

66+
/*
67+
* digitalPinToTimer(..) is AVR-specific and is not defined for SAMD
68+
* architecture. If you need to check if a pin supports PWM you must
69+
* use digitalPinHasPWM(..).
70+
*
71+
* https://github.com/arduino/Arduino/issues/1833
72+
*/
73+
// #define digitalPinToTimer(P)
74+
6775
// Interrupts
6876
#define digitalPinToInterrupt(P) ( g_APinDescription[P].ulExtInt )
6977

0 commit comments

Comments
 (0)