summaryrefslogtreecommitdiffstats
path: root/Modules/stropmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-07-09 10:51:31 (GMT)
committerGuido van Rossum <guido@python.org>1993-07-09 10:51:31 (GMT)
commite22e6442b748f5f4703cb6f221e1e10b320d0295 (patch)
treeb464f80ce6b88f81a4b79cd3270f7990ee14ef4e /Modules/stropmodule.c
parentd05eb8b0fc24c518abcd582e875393886f37689b (diff)
downloadcpython-e22e6442b748f5f4703cb6f221e1e10b320d0295.zip
cpython-e22e6442b748f5f4703cb6f221e1e10b320d0295.tar.gz
cpython-e22e6442b748f5f4703cb6f221e1e10b320d0295.tar.bz2
* config.c: different default PYTHONPATH for MS-DOS
* timemodule.c: change #ifdef TURBO_C into #ifdef MSDOS * posixmodule.c: MSDOS changes by Marcel van der Peijl (Digicash) * stropmodule.c: use C isspace(c) to test for whitespace; add whitespace, lowercase and uppercase variables to the module.
Diffstat (limited to 'Modules/stropmodule.c')
-rw-r--r--Modules/stropmodule.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 6fc2719..4a10b7c 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -28,6 +28,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include <ctype.h>
+/* XXX This file assumes that the <ctype.h> is*() functions
+ XXX are defined for all 8-bit characters! */
static object *
@@ -365,8 +367,6 @@ static struct methodlist strop_methods[] = {
};
-/* Initialization function for the module (*must* be called initstrop) */
-
void
initstrop()
{
@@ -375,12 +375,42 @@ initstrop()
int c, n;
m = initmodule("strop", strop_methods);
d = getmoduledict(m);
+
+ /* Create 'whitespace' object */
n = 0;
for (c = 1; c < 256; c++) {
if (isspace(c))
buf[n++] = c;
}
+ if (s) {
+ s = newsizedstringobject(buf, n);
+ dictinsert(d, "whitespace", s);
+ DECREF(s);
+ }
+ /* Create 'lowercase' object */
+ n = 0;
+ for (c = 1; c < 256; c++) {
+ if (islower(c))
+ buf[n++] = c;
+ }
+ s = newsizedstringobject(buf, n);
+ if (s) {
+ dictinsert(d, "lowercase", s);
+ DECREF(s);
+ }
+
+ /* Create 'uppercase' object */
+ n = 0;
+ for (c = 1; c < 256; c++) {
+ if (isupper(c))
+ buf[n++] = c;
+ }
s = newsizedstringobject(buf, n);
- dictinsert(d, "whitespace", s);
- DECREF(s);
+ if (s) {
+ dictinsert(d, "uppercase", s);
+ DECREF(s);
+ }
+
+ if (err_occurred())
+ fatal("can't initialize module strop");
}