File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed
features/cellular/framework/AT Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -952,25 +952,31 @@ bool ATHandler::consume_char(char ch)
952
952
bool ATHandler::consume_to_tag (const char *tag, bool consume_tag)
953
953
{
954
954
size_t match_pos = 0 ;
955
+ size_t tag_length = strlen (tag);
955
956
956
957
while (true ) {
957
958
int c = get_char ();
958
959
if (c == -1 ) {
959
- break ;
960
- // compares c against tag at current position and if this match fails
961
- // compares c against tag[0] and also resets match_pos to 0
962
- } else if (c == tag[match_pos] || ((match_pos = 1 ) && (c == tag[--match_pos])) ) {
960
+ tr_debug ( " consume_to_tag not found " ) ;
961
+ return false ;
962
+ }
963
+ if (c == tag[match_pos]) {
963
964
match_pos++;
964
- if (match_pos == strlen (tag)) {
965
- if (!consume_tag) {
966
- _recv_pos -= strlen (tag);
967
- }
968
- return true ;
965
+ } else if (match_pos != 0 ) {
966
+ match_pos = 0 ;
967
+ if (c == tag[match_pos]) {
968
+ match_pos++;
969
969
}
970
970
}
971
+ if (match_pos == tag_length) {
972
+ break ;
973
+ }
971
974
}
972
- tr_debug (" consume_to_tag not found" );
973
- return false ;
975
+
976
+ if (!consume_tag) {
977
+ _recv_pos -= tag_length;
978
+ }
979
+ return true ;
974
980
}
975
981
976
982
bool ATHandler::consume_to_stop_tag ()
You can’t perform that action at this time.
0 commit comments