Skip to content

Commit 786296d

Browse files
committed
Evict PERLIO_IS_STDIO from top-level core files.
Configuring with perlio has been the only option since dd35fa1 in 2011, first released in 5.16.0. Yet we have still have had all this dead code for stdio support cluttering up the sources and dulling the machetes of anyone who wants to do further work on perlio or someone (like me) who just stumbles on some code that looks like it needs fixing but isn't worth the time since the compiler will never see it. Leave a vestigial perlsdio.h since its presence is hard-coded in a number of places.
1 parent 1f03351 commit 786296d

File tree

5 files changed

+16
-203
lines changed

5 files changed

+16
-203
lines changed

perlio.c

-24
Original file line numberDiff line numberDiff line change
@@ -338,29 +338,6 @@ Perl_boot_core_PerlIO(pTHX)
338338
#endif
339339

340340

341-
#ifdef PERLIO_IS_STDIO
342-
343-
void
344-
PerlIO_init(pTHX)
345-
{
346-
PERL_UNUSED_CONTEXT;
347-
/*
348-
* Does nothing (yet) except force this file to be included in perl
349-
* binary. That allows this file to force inclusion of other functions
350-
* that may be required by loadable extensions e.g. for
351-
* FileHandle::tmpfile
352-
*/
353-
}
354-
355-
#undef PerlIO_tmpfile
356-
PerlIO *
357-
PerlIO_tmpfile(void)
358-
{
359-
return tmpfile();
360-
}
361-
362-
#else /* PERLIO_IS_STDIO */
363-
364341
/*======================================================================================*/
365342
/*
366343
* Implement all the PerlIO interface ourselves.
@@ -5093,7 +5070,6 @@ Perl_PerlIO_restore_errno(pTHX_ PerlIO *f)
50935070
#undef HAS_FSETPOS
50945071
#undef HAS_FGETPOS
50955072

5096-
#endif /* PERLIO_IS_STDIO */
50975073

50985074
/*======================================================================================*/
50995075
/*

perlio.h

+13-41
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,23 @@
1313
/*
1414
Interface for perl to IO functions.
1515
There is a hierarchy of Configure determined #define controls:
16-
USE_STDIO - forces PerlIO_xxx() to be #define-d onto stdio functions.
17-
This is used for conservative
18-
builds - "just like perl5.00X used to be".
19-
This dominates over the others.
16+
USE_STDIO - No longer available via Configure. Formerly forced
17+
PerlIO_xxx() to be #define-d onto stdio functions.
18+
Now generates compile-time error.
2019
2120
USE_PERLIO - The primary Configure variable that enables PerlIO.
22-
If USE_PERLIO is _NOT_ set
23-
then USE_STDIO above will be set to be conservative.
2421
PerlIO_xxx() are real functions
2522
defined in perlio.c which implement extra functionality
2623
required for utf8 support.
2724
28-
One further note - the table-of-functions scheme controlled
29-
by PERL_IMPLICIT_SYS turns on USE_PERLIO so that iperlsys.h can
30-
#define PerlIO_xxx() to go via the function table, without having
31-
to #undef them from (say) stdio forms.
32-
3325
*/
3426

35-
#if defined(PERL_IMPLICIT_SYS)
36-
#ifndef USE_PERLIO
37-
#ifndef NETWARE
38-
/* # define USE_PERLIO */
39-
#endif
40-
#endif
41-
#endif
42-
4327
#ifndef USE_PERLIO
4428
# define USE_STDIO
4529
#endif
4630

4731
#ifdef USE_STDIO
48-
# ifndef PERLIO_IS_STDIO
49-
# define PERLIO_IS_STDIO
50-
# endif
32+
# error "stdio is no longer supported as the default base layer -- use perlio."
5133
#endif
5234

5335
/* -------------------- End of Configure controls ---------------------------- */
@@ -71,11 +53,6 @@
7153
#undef O_BINARY
7254
#endif
7355

74-
#ifdef PERLIO_IS_STDIO
75-
/* #define PerlIO_xxxx() as equivalent stdio function */
76-
#include "perlsdio.h"
77-
#endif /* PERLIO_IS_STDIO */
78-
7956
#ifndef PerlIO
8057
/* ----------- PerlIO implementation ---------- */
8158
/* PerlIO not #define-d to something else - define the implementation */
@@ -111,27 +88,24 @@ PERL_CALLCONV void PerlIO_clone(pTHX_ PerlInterpreter *proto,
11188

11289
/* ----------- End of implementation choices ---------- */
11390

114-
#ifndef PERLIO_IS_STDIO
115-
/* Not using stdio _directly_ as PerlIO */
116-
11791
/* We now need to determine what happens if source trys to use stdio.
11892
* There are three cases based on PERLIO_NOT_STDIO which XS code
11993
* can set how it wants.
12094
*/
12195

122-
# ifdef PERL_CORE
96+
#ifdef PERL_CORE
12397
/* Make a choice for perl core code
12498
- currently this is set to try and catch lingering raw stdio calls.
12599
This is a known issue with some non UNIX ports which still use
126100
"native" stdio features.
127101
*/
128-
# ifndef PERLIO_NOT_STDIO
129-
# define PERLIO_NOT_STDIO 1
130-
# endif
131-
#else
132-
# ifndef PERLIO_NOT_STDIO
133-
# define PERLIO_NOT_STDIO 0
134-
# endif
102+
# ifndef PERLIO_NOT_STDIO
103+
# define PERLIO_NOT_STDIO 1
104+
# endif
105+
#else
106+
# ifndef PERLIO_NOT_STDIO
107+
# define PERLIO_NOT_STDIO 0
108+
# endif
135109
#endif
136110

137111
#ifdef PERLIO_NOT_STDIO
@@ -154,7 +128,6 @@ PERL_CALLCONV void PerlIO_clone(pTHX_ PerlInterpreter *proto,
154128
*/
155129
#include "fakesdio.h"
156130
#endif /* ifndef PERLIO_NOT_STDIO */
157-
#endif /* PERLIO_IS_STDIO */
158131

159132
/* ----------- fill in things that have not got #define'd ---------- */
160133

@@ -331,7 +304,7 @@ PERL_CALLCONV int PerlIO_setpos(PerlIO *, SV *);
331304
#ifndef PerlIO_fdupopen
332305
PERL_CALLCONV PerlIO *PerlIO_fdupopen(pTHX_ PerlIO *, CLONE_PARAMS *, int);
333306
#endif
334-
#if !defined(PerlIO_modestr) && !defined(PERLIO_IS_STDIO)
307+
#if !defined(PerlIO_modestr)
335308
PERL_CALLCONV char *PerlIO_modestr(PerlIO *, char *buf);
336309
#endif
337310
#ifndef PerlIO_isutf8
@@ -360,7 +333,6 @@ PERL_CALLCONV void PerlIO_debug(const char *fmt, ...)
360333
__attribute__format__(__printf__, 1, 2);
361334
typedef struct PerlIO_list_s PerlIO_list_t;
362335

363-
364336
#endif
365337

366338
END_EXTERN_C

perlsdio.h

+3-124
Original file line numberDiff line numberDiff line change
@@ -8,133 +8,12 @@
88
*
99
*/
1010

11-
#ifdef PERLIO_IS_STDIO
12-
13-
#ifdef NETWARE
14-
#include "nwstdio.h"
15-
#else
16-
17-
/*
18-
* This file #define-s the PerlIO_xxx abstraction onto stdio functions.
19-
* Make this as close to original stdio as possible.
20-
*/
21-
#define PerlIO FILE
22-
#define PerlIO_stderr() PerlSIO_stderr
23-
#define PerlIO_stdout() PerlSIO_stdout
24-
#define PerlIO_stdin() PerlSIO_stdin
25-
26-
#define PerlIO_isutf8(f) 0
27-
28-
#define PerlIO_printf PerlSIO_printf
29-
#define PerlIO_stdoutf PerlSIO_stdoutf
30-
#define PerlIO_vprintf(f,fmt,a) PerlSIO_vprintf(f,fmt,a)
31-
#define PerlIO_write(f,buf,count) PerlSIO_fwrite(buf,1,count,f)
32-
#define PerlIO_unread(f,buf,count) (-1)
33-
#define PerlIO_open PerlSIO_fopen
34-
#define PerlIO_fdopen PerlSIO_fdopen
35-
#define PerlIO_reopen PerlSIO_freopen
36-
#define PerlIO_close(f) PerlSIO_fclose(f)
37-
#define PerlIO_puts(f,s) PerlSIO_fputs(s,f)
38-
#define PerlIO_putc(f,c) PerlSIO_fputc(c,f)
39-
#if defined(__VMS)
40-
/* Unusual definition of ungetc() here to accommodate fast_sv_gets()'
41-
* belief that it can mix getc/ungetc with reads from stdio buffer */
42-
START_EXTERN_C
43-
int decc$ungetc(int __c, FILE *__stream);
44-
END_EXTERN_C
45-
# define PerlIO_ungetc(f,c) ((c) == EOF ? EOF : \
46-
((*(f) && !((*(f))->_flag & _IONBF) && \
47-
((*(f))->_ptr > (*(f))->_base)) ? \
48-
((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f)))
49-
#else
50-
# define PerlIO_ungetc(f,c) PerlSIO_ungetc(c,f)
51-
#endif
52-
#define PerlIO_getc(f) PerlSIO_fgetc(f)
53-
#define PerlIO_read(f,buf,count) (SSize_t)PerlSIO_fread(buf,1,count,f)
54-
#define PerlIO_tell(f) PerlSIO_ftell(f)
55-
#define PerlIO_eof(f) PerlSIO_feof(f)
56-
#define PerlIO_getname(f,b) fgetname(f,b)
57-
#define PerlIO_error(f) PerlSIO_ferror(f)
58-
#define PerlIO_fileno(f) PerlSIO_fileno(f)
59-
#define PerlIO_clearerr(f) PerlSIO_clearerr(f)
60-
#define PerlIO_flush(f) PerlSIO_fflush(f)
61-
#define PerlIO_seek(f,o,w) PerlSIO_fseek(f,o,w)
62-
63-
#define PerlIO_rewind(f) PerlSIO_rewind(f)
64-
#define PerlIO_tmpfile() PerlSIO_tmpfile()
65-
66-
#define PerlIO_importFILE(f,fl) (f)
67-
#define PerlIO_exportFILE(f,fl) (f)
68-
#define PerlIO_findFILE(f) (f)
69-
#define PerlIO_releaseFILE(p,f) ((void) 0)
70-
71-
#ifdef HAS_SETLINEBUF
72-
#define PerlIO_setlinebuf(f) PerlSIO_setlinebuf(f);
73-
#else
74-
#define PerlIO_setlinebuf(f) PerlSIO_setvbuf(f, NULL, _IOLBF, 0);
75-
#endif
76-
77-
/* Now our interface to Configure's FILE_xxx macros */
78-
79-
#ifdef USE_STDIO_PTR
80-
#define PerlIO_has_cntptr(f) 1
81-
#define PerlIO_get_ptr(f) PerlSIO_get_ptr(f)
82-
#define PerlIO_get_cnt(f) PerlSIO_get_cnt(f)
83-
84-
#ifdef STDIO_CNT_LVALUE
85-
#define PerlIO_canset_cnt(f) 1
86-
#define PerlIO_set_cnt(f,c) PerlSIO_set_cnt(f,c)
87-
#ifdef STDIO_PTR_LVALUE
88-
#ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
89-
#define PerlIO_fast_gets(f) 1
90-
#endif
91-
#endif /* STDIO_PTR_LVALUE */
92-
#else /* STDIO_CNT_LVALUE */
93-
#define PerlIO_canset_cnt(f) 0
94-
#define PerlIO_set_cnt(f,c) abort()
95-
#endif
96-
97-
#ifdef STDIO_PTR_LVALUE
98-
#ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
99-
#define PerlIO_set_ptrcnt(f,p,c) STMT_START {PerlSIO_set_ptr(f,p), PerlIO_set_cnt(f,c);} STMT_END
100-
#else
101-
#ifdef STDIO_PTR_LVAL_SETS_CNT
102-
/* assert() may pre-process to ""; potential syntax error (FILE_ptr(), ) */
103-
#define PerlIO_set_ptrcnt(f,p,c) STMT_START {PerlSIO_set_ptr(f,p); assert(PerlSIO_get_cnt(f) == (c));} STMT_END
104-
#define PerlIO_fast_gets(f) 1
105-
#else
106-
#define PerlIO_set_ptrcnt(f,p,c) abort()
107-
#endif
108-
#endif
109-
#endif
110-
111-
#else /* USE_STDIO_PTR */
112-
113-
#define PerlIO_has_cntptr(f) 0
114-
#define PerlIO_canset_cnt(f) 0
115-
#define PerlIO_get_cnt(f) (abort(),0)
116-
#define PerlIO_get_ptr(f) (abort(),(void *)0)
117-
#define PerlIO_set_cnt(f,c) abort()
118-
#define PerlIO_set_ptrcnt(f,p,c) abort()
119-
120-
#endif /* USE_STDIO_PTR */
121-
122-
#ifndef PerlIO_fast_gets
123-
#define PerlIO_fast_gets(f) 0
124-
#endif
11+
/* Shouldn't be possible to get here, but if we did ... */
12512

13+
#ifdef PERLIO_IS_STDIO
12614

127-
#ifdef FILE_base
128-
#define PerlIO_has_base(f) 1
129-
#define PerlIO_get_base(f) PerlSIO_get_base(f)
130-
#define PerlIO_get_bufsiz(f) PerlSIO_get_bufsiz(f)
131-
#else
132-
#define PerlIO_has_base(f) 0
133-
#define PerlIO_get_base(f) (abort(),(void *)0)
134-
#define PerlIO_get_bufsiz(f) (abort(),0)
135-
#endif
15+
# error "stdio is no longer supported as the default base layer -- use perlio."
13616

137-
#endif /* NETWARE */
13817
#endif /* PERLIO_IS_STDIO */
13918

14019
/*

pp_ctl.c

-4
Original file line numberDiff line numberDiff line change
@@ -3517,11 +3517,7 @@ S_check_type_and_open(pTHX_ SV *name)
35173517
}
35183518
#endif
35193519

3520-
#if !defined(PERLIO_IS_STDIO)
35213520
retio = PerlIO_openn(aTHX_ ":", PERL_SCRIPT_MODE, -1, 0, 0, NULL, 1, &name);
3522-
#else
3523-
retio = PerlIO_open(p, PERL_SCRIPT_MODE);
3524-
#endif
35253521
#ifdef WIN32
35263522
/* EACCES stops the INC search early in pp_require to implement
35273523
feature RT #113422 */

sv.c

-10
Original file line numberDiff line numberDiff line change
@@ -8245,16 +8245,6 @@ Perl_sv_gets(pTHX_ SV *const sv, PerlIO *const fp, I32 append)
82458245
amount left, otherwise this is the amount it
82468246
can hold. */
82478247

8248-
#if defined(__VMS) && defined(PERLIO_IS_STDIO)
8249-
/* An ungetc()d char is handled separately from the regular
8250-
* buffer, so we getc() it back out and stuff it in the buffer.
8251-
*/
8252-
i = PerlIO_getc(fp);
8253-
if (i == EOF) return 0;
8254-
*(--((*fp)->_ptr)) = (unsigned char) i;
8255-
(*fp)->_cnt++;
8256-
#endif
8257-
82588248
/* Here is some breathtakingly efficient cheating */
82598249

82608250
/* When you read the following logic resist the urge to think

0 commit comments

Comments
 (0)