diff options
author | Guido van Rossum <guido@python.org> | 1991-04-04 10:44:06 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-04-04 10:44:06 (GMT) |
commit | eb183da74fa48b51695732294a90897c5ec5c850 (patch) | |
tree | 5a166af7cf3f222d71df2c4c11237c0210693974 /Objects | |
parent | 282914b7b063e278b133aba58ef4876f6210a67a (diff) | |
download | cpython-eb183da74fa48b51695732294a90897c5ec5c850.zip cpython-eb183da74fa48b51695732294a90897c5ec5c850.tar.gz cpython-eb183da74fa48b51695732294a90897c5ec5c850.tar.bz2 |
Added 'softspace' interface to replace 'needspace' printing hack.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/fileobject.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index f038327..255b23e 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -44,7 +44,7 @@ typedef struct { FILE *f_fp; object *f_name; object *f_mode; - /* XXX Should move the 'need space' on printing flag here */ + int f_softspace; /* Flag used by 'print' command */ } fileobject; FILE * @@ -70,6 +70,7 @@ newopenfileobject(fp, name, mode) f->f_fp = NULL; f->f_name = newstringobject(name); f->f_mode = newstringobject(mode); + f->f_softspace = 0; if (f->f_name == NULL || f->f_mode == NULL) { DECREF(f); return NULL; @@ -387,6 +388,7 @@ file_write(f, args) err_badarg(); return NULL; } + f->f_softspace = 0; errno = 0; n2 = fwrite(getstringvalue(args), 1, n = getstringsize(args), f->f_fp); if (n2 != n) { @@ -432,3 +434,18 @@ typeobject Filetype = { 0, /*tp_compare*/ file_repr, /*tp_repr*/ }; + +/* Interface for the 'soft space' between print items. */ + +int +softspace(f, newflag) + object *f; + int newflag; +{ + int oldflag = 0; + if (f != NULL && is_fileobject(f)) { + oldflag = ((fileobject *)f)->f_softspace; + ((fileobject *)f)->f_softspace = newflag; + } + return oldflag; +} |