[Scummvm-cvs-logs] scummvm master -> 2773f5d7afc381205b5e0fcb8b20700007472516

lordhoto lordhoto at gmail.com
Thu Dec 13 21:10:23 CET 2012


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b0ba4b01a4 COMMON: Add wrapper for isprint.
2773f5d7af COMMON: Forbid symbols for the rest of is* from ctype.h.


Commit: b0ba4b01a4fee3409768bdced4de6719b51297bc
    https://github.com/scummvm/scummvm/commit/b0ba4b01a4fee3409768bdced4de6719b51297bc
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-12-13T12:08:47-08:00

Commit Message:
COMMON: Add wrapper for isprint.

This is done in the spirit of 658080deeda79d20ea40643569fbcb072573e7cf.

Changed paths:
    common/forbidden.h
    common/str.cpp
    common/util.cpp
    common/util.h
    engines/hugo/parser.cpp
    engines/queen/journal.cpp
    engines/touche/menu.cpp
    gui/widgets/list.cpp



diff --git a/common/forbidden.h b/common/forbidden.h
index eec80bb..46890e0 100644
--- a/common/forbidden.h
+++ b/common/forbidden.h
@@ -358,6 +358,11 @@
 	#define isupper(a)	FORBIDDEN_SYMBOL_REPLACEMENT
 	#endif
 
+	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isprint
+	#undef isprint
+	#define isprint(a)	FORBIDDEN_SYMBOL_REPLACEMENT
+	#endif
+
 #endif // FORBIDDEN_SYMBOL_EXCEPTION_ctype_h
 
 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_mkdir
diff --git a/common/str.cpp b/common/str.cpp
index 8480508..8210ca6 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -764,7 +764,7 @@ String tag2string(uint32 tag) {
 	str[4] = '\0';
 	// Replace non-printable chars by dot
 	for (int i = 0; i < 4; ++i) {
-		if (!isprint((unsigned char)str[i]))
+		if (!Common::isPrint(str[i]))
 			str[i] = '.';
 	}
 	return String(str);
diff --git a/common/util.cpp b/common/util.cpp
index 4d9ff11..3d40fff 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -26,6 +26,7 @@
 #define FORBIDDEN_SYMBOL_EXCEPTION_islower
 #define FORBIDDEN_SYMBOL_EXCEPTION_isspace
 #define FORBIDDEN_SYMBOL_EXCEPTION_isupper
+#define FORBIDDEN_SYMBOL_EXCEPTION_isprint
 
 
 #include "common/util.h"
@@ -144,4 +145,8 @@ bool isUpper(int c) {
 	return isupper((byte)c);
 }
 
+bool isPrint(int c) {
+	ENSURE_ASCII_CHAR(c);
+	return isprint((byte)c);
+}
 } // End of namespace Common
diff --git a/common/util.h b/common/util.h
index 7834098..4ca1c42 100644
--- a/common/util.h
+++ b/common/util.h
@@ -165,6 +165,17 @@ bool isSpace(int c);
  */
 bool isUpper(int c);
 
-}	// End of namespace Common
+/**
+ * Test whether the given character is printable. This includes the space
+ * character (' ').
+ *
+ * If the parameter is outside the range of a signed or unsigned char, then
+ * false is returned.
+ *
+ * @param c		the character to test
+ * @return		true if the character is printable, false otherwise.
+ */
+bool isPrint(int c);
+} // End of namespace Common
 
 #endif
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index 5fdb202..2585c64 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -235,7 +235,7 @@ void Parser::charHandler() {
 			if (_cmdLineIndex >= kMaxLineSize) {
 				//MessageBeep(MB_ICONASTERISK);
 				warning("STUB: MessageBeep() - Command line too long");
-			} else if (isprint(static_cast<unsigned char>(c))) {
+			} else if (Common::isPrint(c)) {
 				_cmdLine[_cmdLineIndex++] = c;
 				_cmdLine[_cmdLineIndex] = '\0';
 			}
diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp
index db06d54..474f72e 100644
--- a/engines/queen/journal.cpp
+++ b/engines/queen/journal.cpp
@@ -559,7 +559,7 @@ void Journal::updateTextField(uint16 ascii, int keycode) {
 		}
 		break;
 	default:
-		if (isprint((char)ascii) &&
+		if (Common::isPrint((char)ascii) &&
 			_textField.textCharsCount < (sizeof(_textField.text) - 1) &&
 			_vm->display()->textWidth(_textField.text) < _textField.w) {
 			_textField.text[_textField.textCharsCount] = (char)ascii;
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index c58e2f1..46429eb 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -103,7 +103,7 @@ struct MenuData {
 	void addCharToDescription(int slot, char chr) {
 		char *description = saveLoadDescriptionsTable[slot];
 		int descriptionLen = strlen(description);
-		if (descriptionLen < 32 && isprint(static_cast<unsigned char>(chr))) {
+		if (descriptionLen < 32 && Common::isPrint(chr)) {
 			description[descriptionLen] = chr;
 			description[descriptionLen + 1] = 0;
 		}
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 13784dd..95d39c4 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -284,7 +284,7 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
 	bool dirty = false;
 	int oldSelectedItem = _selectedItem;
 
-	if (!_editMode && state.keycode <= Common::KEYCODE_z && isprint((unsigned char)state.ascii)) {
+	if (!_editMode && state.keycode <= Common::KEYCODE_z && Common::isPrint(state.ascii)) {
 		// Quick selection mode: Go to first list item starting with this key
 		// (or a substring accumulated from the last couple key presses).
 		// Only works in a useful fashion if the list entries are sorted.


Commit: 2773f5d7afc381205b5e0fcb8b20700007472516
    https://github.com/scummvm/scummvm/commit/2773f5d7afc381205b5e0fcb8b20700007472516
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-12-13T12:08:48-08:00

Commit Message:
COMMON: Forbid symbols for the rest of is* from ctype.h.

I also moved the isprint case to the correct position.

This adds a FIXME to our lua code from sword25, which uses iscntrl directly.

Changed paths:
    common/forbidden.h
    engines/sword25/util/lua/llex.cpp



diff --git a/common/forbidden.h b/common/forbidden.h
index 46890e0..9050114 100644
--- a/common/forbidden.h
+++ b/common/forbidden.h
@@ -333,11 +333,21 @@
 	#define isalpha(a)	FORBIDDEN_SYMBOL_REPLACEMENT
 	#endif
 
+	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_iscntrl
+	#undef iscntrl
+	#define iscntrl(a)	FORBIDDEN_SYMBOL_REPLACEMENT
+	#endif
+
 	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isdigit
 	#undef isdigit
 	#define isdigit(a)	FORBIDDEN_SYMBOL_REPLACEMENT
 	#endif
 
+	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isgraph
+	#undef isgraph
+	#define isgraph(a)	FORBIDDEN_SYMBOL_REPLACEMENT
+	#endif
+
 	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isnumber
 	#undef isnumber
 	#define isnumber(a)	FORBIDDEN_SYMBOL_REPLACEMENT
@@ -348,6 +358,16 @@
 	#define islower(a)	FORBIDDEN_SYMBOL_REPLACEMENT
 	#endif
 
+	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isprint
+	#undef isprint
+	#define isprint(a)	FORBIDDEN_SYMBOL_REPLACEMENT
+	#endif
+
+	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_ispunct
+	#undef ispunct
+	#define ispunct(a)	FORBIDDEN_SYMBOL_REPLACEMENT
+	#endif
+
 	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isspace
 	#undef isspace
 	#define isspace(a)	FORBIDDEN_SYMBOL_REPLACEMENT
@@ -358,9 +378,9 @@
 	#define isupper(a)	FORBIDDEN_SYMBOL_REPLACEMENT
 	#endif
 
-	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isprint
-	#undef isprint
-	#define isprint(a)	FORBIDDEN_SYMBOL_REPLACEMENT
+	#ifndef FORBIDDEN_SYMBOL_EXCEPTION_isxdigit
+	#undef isxdigit
+	#define isxdigit(a)	FORBIDDEN_SYMBOL_REPLACEMENT
 	#endif
 
 #endif // FORBIDDEN_SYMBOL_EXCEPTION_ctype_h
diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp
index f8433d3..423f028 100644
--- a/engines/sword25/util/lua/llex.cpp
+++ b/engines/sword25/util/lua/llex.cpp
@@ -4,6 +4,8 @@
 ** See Copyright Notice in lua.h
 */
 
+// FIXME: Do not directly use iscntrl from ctype.h.
+#define FORBIDDEN_SYMBOL_EXCEPTION_iscntrl
 
 #include "common/util.h"
 






More information about the Scummvm-git-logs mailing list