你好我的一些问题我已经调查了一下,有人说这是一个带有Java的RegEx错误,但我甚至认为Energia没有使用Java ...有点混淆为什么这个错误弹出C代码。
ERROR:
Exception in thread "Thread-5" java.lang.StackOverflowError
at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
......它还有数百条相同的东西。
至于正则表达式代码:
请注意,在这种情况下,我在我的图像部分(这是导致错误的字段)中硬编码仅用于测试目的,我想通过网络将带有base64编码的JSON消息传输到Web服务将它作为图片转发到我的电子邮件。
如果缩短图像字符串,则不会发生错误,但当然这对于传输实际图片来说太小了。真的很感谢你的帮助!
// [7.12.2] Class template regex_token_iterator
/**
* Iterates over submatches in a range (or @a splits a text string).
*
* The purpose of this iterator is to enumerate all, or all specified,
* matches of a regular expression within a text range. The dereferenced
* value of an iterator of this class is a std::tr1::sub_match object.
*/
template<typename _Bi_iter,
typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
typename _Rx_traits = regex_traits<_Ch_type> >
class regex_token_iterator
{
public:
typedef basic_regex<_Ch_type, _Rx_traits> regex_type;
typedef sub_match<_Bi_iter> value_type;
typedef std::ptrdiff_t difference_type;
typedef const value_type* pointer;
typedef const value_type& reference;
typedef std::forward_iterator_tag iterator_category;
public:
/**
* @brief Default constructs a %regex_token_iterator.
* @todo Implement this function.
*
* A default-constructed %regex_token_iterator is a singular iterator
* that will compare equal to the one-past-the-end value for any
* iterator of the same type.
*/
regex_token_iterator();
/**
* Constructs a %regex_token_iterator...
* @param a [IN] The start of the text to search.
* @param b [IN] One-past-the-end of the text to search.
* @param re [IN] The regular expression to search for.
* @param submatch [IN] Which submatch to return. There are some
* special values for this parameter:
* - -1 each enumerated subexpression does NOT
* match the regular expression (aka field
* splitting)
* - 0 the entire string matching the
* subexpression is returned for each match
* within the text.
* - >0 enumerates only the indicated
* subexpression from a match within the text.
* @param m [IN] Policy flags for match rules.
*
* @todo Implement this function.
* @doctodo
*/
regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re,
int __submatch = 0,
regex_constants::match_flag_type __m
= regex_constants::match_default);
/**
* Constructs a %regex_token_iterator...
* @param a [IN] The start of the text to search.
* @param b [IN] One-past-the-end of the text to search.
* @param re [IN] The regular expression to search for.
* @param submatches [IN] A list of subexpressions to return for each
* regular expression match within the text.
* @param m [IN] Policy flags for match rules.
*
* @todo Implement this function.
* @doctodo
*/
regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
const regex_type& __re,
const std::vector<int>& __submatches,
regex_constants::match_flag_type __m
= regex_constants::match_default);
/**
* Constructs a %regex_token_iterator...
* @param a [IN] The start of the text to search.
* @param b [IN] One-past-the-end of the text to search.
* @param re [IN] The regular expression to search for.
* @param submatches [IN] A list of subexpressions to return for each
* regular expression match within the text.
* @param m [IN] Policy flags for match rules.
* @todo Implement this function.
* @doctodo
*/
template<std::size_t _Nm>
regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
const regex_type& __re,
const int (&__submatches)[_Nm],
regex_constants::match_flag_type __m
= regex_constants::match_default);
/**
* @brief Copy constructs a %regex_token_iterator.
* @param rhs [IN] A %regex_token_iterator to copy.
* @todo Implement this function.
*/
regex_token_iterator(const regex_token_iterator& __rhs);
/**
* @brief Assigns a %regex_token_iterator to another.
* @param rhs [IN] A %regex_token_iterator to copy.
* @todo Implement this function.
*/
regex_token_iterator&
operator=(const regex_token_iterator& __rhs);
/**
* @brief Compares a %regex_token_iterator to another for equality.
* @todo Implement this function.
*/
bool
operator==(const regex_token_iterator& __rhs);
/**
* @brief Compares a %regex_token_iterator to another for inequality.
* @todo Implement this function.
*/
bool
operator!=(const regex_token_iterator& __rhs);
/**
* @brief Dereferences a %regex_token_iterator.
* @todo Implement this function.
*/
const value_type&
operator*();
/**
* @brief Selects a %regex_token_iterator member.
* @todo Implement this function.
*/
const value_type*
operator->();
/**
* @brief Increments a %regex_token_iterator.
* @todo Implement this function.
*/
regex_token_iterator&
operator++();
/**
* @brief Postincrements a %regex_token_iterator.
* @todo Implement this function.
*/
regex_token_iterator
operator++(int);
private: // data members for exposition only:
typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator;
position_iterator __position;
const value_type* __result;
value_type __suffix;
std::size_t __n;
std::vector<int> __subs;
};
/** @brief Token iterator for C-style NULL-terminated strings. */
typedef regex_token_iterator<const char*> cregex_token_iterator;
/** @brief Token iterator for standard strings. */
typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
#ifdef _GLIBCXX_USE_WCHAR_T
/** @brief Token iterator for C-style NULL-terminated wide strings. */
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
/** @brief Token iterator for standard wide-character strings. */
typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
#endif
base64.c:
#include <string.h>
#include "base64.h"
/* aaaack but it's fast and const should make it shared text page. */
static const unsigned char pr2six[256] =
{
/* ASCII table */
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64,
64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
};
int Base64decode_len(const char *bufcoded)
{
int nbytesdecoded;
register const unsigned char *bufin;
register int nprbytes;
bufin = (const unsigned char *) bufcoded;
while (pr2six[*(bufin++)] <= 63);
nprbytes = (bufin - (const unsigned char *) bufcoded) - 1;
nbytesdecoded = ((nprbytes + 3) / 4) * 3;
return nbytesdecoded + 1;
}
int Base64decode(char *bufplain, const char *bufcoded)
{
int nbytesdecoded;
register const unsigned char *bufin;
register unsigned char *bufout;
register int nprbytes;
bufin = (const unsigned char *) bufcoded;
while (pr2six[*(bufin++)] <= 63);
nprbytes = (bufin - (const unsigned char *) bufcoded) - 1;
nbytesdecoded = ((nprbytes + 3) / 4) * 3;
bufout = (unsigned char *) bufplain;
bufin = (const unsigned char *) bufcoded;
while (nprbytes > 4) {
*(bufout++) =
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
*(bufout++) =
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
*(bufout++) =
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
bufin += 4;
nprbytes -= 4;
}
/* Note: (nprbytes == 1) would be an error, so just ingore that case */
if (nprbytes > 1) {
*(bufout++) =
(unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4);
}
if (nprbytes > 2) {
*(bufout++) =
(unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2);
}
if (nprbytes > 3) {
*(bufout++) =
(unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]);
}
*(bufout++) = '\0';
nbytesdecoded -= (4 - nprbytes) & 3;
return nbytesdecoded;
}
static const char basis_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int Base64encode_len(int len)
{
return ((len + 2) / 3 * 4) + 1;
}
int Base64encode(char *encoded, const char *string, int len)
{
int i;
char *p;
p = encoded;
for (i = 0; i < len - 2; i += 3) {
*p++ = basis_64[(string[i] >> 2) & 0x3F];
*p++ = basis_64[((string[i] & 0x3) << 4) |
((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2) |
((int) (string[i + 2] & 0xC0) >> 6)];
*p++ = basis_64[string[i + 2] & 0x3F];
}
if (i < len) {
*p++ = basis_64[(string[i] >> 2) & 0x3F];
if (i == (len - 1)) {
*p++ = basis_64[((string[i] & 0x3) << 4)];
*p++ = '=';
}
else {
*p++ = basis_64[((string[i] & 0x3) << 4) |
((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2)];
}
*p++ = '=';
}
*p++ = '\0';
return p - encoded;
}
base64.h:
#ifndef _BASE64_H_
#define _BASE64_H_
#ifdef __cplusplus
extern "C" {
#endif
int Base64encode_len(int len);
int Base64encode(char * coded_dst, const char *plain_src,int len_plain_src);
int Base64decode_len(const char * coded_src);
int Base64decode(char * plain_dst, const char *coded_src);
#ifdef __cplusplus
}
#endif
#endif //_BASE64_H_
进一步解释:当我尝试插入带有预编码的base64文本的jpeg图像时,会触发此错误...我想确保在尝试实例化嵌入式摄像头之前可以传输虚拟图像。我很确定它不是base64代码,而是Java Regex,我对此一无所知(只是它处理标记长字符串并且似乎与错误相关)。也许它试图在字符串中找到一个模式,因为它是一个非常长的随机字符串,它无法做到这一点然后出错?
答案 0 :(得分:0)
对于与Java正则表达式相关的长字符串,IDE令牌解析似乎是一个问题。可以联系他们的dicussion论坛获取更多信息。