< prev index next >
jdk/src/java.desktop/windows/native/libawt/windows/awt_TextField.cpp
Print this page
@@ -281,10 +281,42 @@
env->DeleteGlobalRef(self);
delete secs;
}
+/*
+Remove any LF, CRLF i.e. EOL characters from pStr
+*/
+int AwtTextField::RemoveEOL(WCHAR *pStr)
+{
+ int i, nLen = 0;
+ if (pStr) {
+ /* check to see if there are any LF's */
+ if (wcschr(pStr, L'\n') == NULL) {
+ return static_cast<int>(wcslen(pStr));
+ }
+
+ for (i = 0; pStr[i] != 0; i++) {
+ if (m_isLFonly == TRUE) {
+ if (pStr[i] == L'\n') {
+ pStr[nLen++] = ' ';
+ continue;
+ }
+ }
+ else {
+ if (pStr[i] == L'\r' && pStr[i + 1] == L'\n') {
+ pStr[nLen++] = ' ';
+ ++i;
+ continue;
+ }
+ }
+ pStr[nLen++] = pStr[i];
+ }
+ pStr[nLen] = 0;
+ }
+ return nLen;
+}
/************************************************************************
* WTextFieldPeer native methods
*/
< prev index next >