diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-10-31 01:43:49 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1997-10-31 01:43:49 +0000 |
commit | 8ac853655d9b744749adcb9687c13d99cdd6e9fb (patch) | |
tree | c32146679d3473063e5fce6090b93706d7602ad6 /util.c | |
parent | 27332437a2ed19419cce5a4de680085fd4d13c8d (diff) | |
download | perl-8ac853655d9b744749adcb9687c13d99cdd6e9fb.tar.gz |
Convert miniperl sources to ANSI C. Several passes of
GNU C's 'protoize' plus a few hand edits.
Will compile miniperl with gcc -x c++ (i.e. treat .c a C++ files)
Does not link seems gcc's C++ does not define a symbol for
const char foo[] = "....";
i.e. with empty [].
p4raw-id: //depot/ansiperl@194
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 162 |
1 files changed, 47 insertions, 115 deletions
@@ -282,13 +282,7 @@ xstat() /* copy a string up to some (non-backslashed) delimiter, if any */ char * -delimcpy(to, toend, from, fromend, delim, retlen) -register char *to; -register char *toend; -register char *from; -register char *fromend; -register int delim; -I32 *retlen; +delimcpy(register char *to, register char *toend, register char *from, register char *fromend, register int delim, I32 *retlen) { register I32 tolen; for (tolen = 0; from < fromend; from++, tolen++) { @@ -317,9 +311,7 @@ I32 *retlen; /* This routine was donated by Corey Satten. */ char * -instr(big, little) -register char *big; -register char *little; +instr(register char *big, register char *little) { register char *s, *x; register I32 first; @@ -349,11 +341,7 @@ register char *little; /* same as instr but allow embedded nulls */ char * -ninstr(big, bigend, little, lend) -register char *big; -register char *bigend; -char *little; -char *lend; +ninstr(register char *big, register char *bigend, char *little, char *lend) { register char *s, *x; register I32 first = *little; @@ -382,11 +370,7 @@ char *lend; /* reverse of the above--find last substring */ char * -rninstr(big, bigend, little, lend) -register char *big; -char *bigend; -char *little; -char *lend; +rninstr(register char *big, char *bigend, char *little, char *lend) { register char *bigbeg; register char *s, *x; @@ -416,8 +400,7 @@ char *lend; * Set up for a new ctype locale. */ void -perl_new_ctype(newctype) - char *newctype; +perl_new_ctype(char *newctype) { #ifdef USE_LOCALE_CTYPE @@ -439,8 +422,7 @@ perl_new_ctype(newctype) * Set up for a new collation locale. */ void -perl_new_collate(newcoll) - char *newcoll; +perl_new_collate(char *newcoll) { #ifdef USE_LOCALE_COLLATE @@ -484,8 +466,7 @@ perl_new_collate(newcoll) * Set up for a new numeric locale. */ void -perl_new_numeric(newnum) - char *newnum; +perl_new_numeric(char *newnum) { #ifdef USE_LOCALE_NUMERIC @@ -510,7 +491,7 @@ perl_new_numeric(newnum) } void -perl_set_numeric_standard() +perl_set_numeric_standard(void) { #ifdef USE_LOCALE_NUMERIC @@ -524,7 +505,7 @@ perl_set_numeric_standard() } void -perl_set_numeric_local() +perl_set_numeric_local(void) { #ifdef USE_LOCALE_NUMERIC @@ -542,8 +523,7 @@ perl_set_numeric_local() * Initialize locale awareness. */ int -perl_init_i18nl10n(printwarn) - int printwarn; +perl_init_i18nl10n(int printwarn) { int ok = 1; /* returns @@ -772,8 +752,7 @@ perl_init_i18nl10n(printwarn) /* Backwards compatibility. */ int -perl_init_i18nl14n(printwarn) - int printwarn; +perl_init_i18nl14n(int printwarn) { return perl_init_i18nl10n(printwarn); } @@ -788,10 +767,7 @@ perl_init_i18nl14n(printwarn) * Please see sv_collxfrm() to see how this is used. */ char * -mem_collxfrm(s, len, xlen) - const char *s; - STRLEN len; - STRLEN *xlen; +mem_collxfrm(const char *s, STRLEN len, STRLEN *xlen) { char *xbuf; STRLEN xalloc, xin, xout; @@ -841,8 +817,7 @@ mem_collxfrm(s, len, xlen) #endif /* USE_LOCALE_COLLATE */ void -fbm_compile(sv) -SV *sv; +fbm_compile(SV *sv) { register unsigned char *s; register unsigned char *table; @@ -883,10 +858,7 @@ SV *sv; } char * -fbm_instr(big, bigend, littlestr) -unsigned char *big; -register unsigned char *bigend; -SV *littlestr; +fbm_instr(unsigned char *big, register unsigned char *bigend, SV *littlestr) { register unsigned char *s; register I32 tmp; @@ -959,9 +931,7 @@ SV *littlestr; } char * -screaminstr(bigstr, littlestr) -SV *bigstr; -SV *littlestr; +screaminstr(SV *bigstr, SV *littlestr) { register unsigned char *s, *x; register unsigned char *big; @@ -1020,9 +990,7 @@ SV *littlestr; } I32 -ibcmp(s1, s2, len) -char *s1, *s2; -register I32 len; +ibcmp(char *s1, char *s2, register I32 len) { register U8 *a = (U8 *)s1; register U8 *b = (U8 *)s2; @@ -1035,9 +1003,7 @@ register I32 len; } I32 -ibcmp_locale(s1, s2, len) -char *s1, *s2; -register I32 len; +ibcmp_locale(char *s1, char *s2, register I32 len) { register U8 *a = (U8 *)s1; register U8 *b = (U8 *)s2; @@ -1052,8 +1018,7 @@ register I32 len; /* copy a string to a safe spot */ char * -savepv(sv) -char *sv; +savepv(char *sv) { register char *newaddr; @@ -1065,9 +1030,7 @@ char *sv; /* same thing but with a known length */ char * -savepvn(sv, len) -char *sv; -register I32 len; +savepvn(char *sv, register I32 len) { register char *newaddr; @@ -1080,7 +1043,7 @@ register I32 len; /* the SV for form() and mess() is not kept in an arena */ static SV * -mess_alloc() +mess_alloc(void) { SV *sv; XPVMG *any; @@ -1119,9 +1082,7 @@ form(pat, va_alist) } char * -mess(pat, args) - const char *pat; - va_list *args; +mess(const char *pat, va_list *args) { SV *sv; static char dgd[] = " during global destruction.\n"; @@ -1350,8 +1311,7 @@ warn(pat,va_alist) #ifndef VMS /* VMS' my_setenv() is in VMS.c */ #ifndef WIN32 void -my_setenv(nam,val) -char *nam, *val; +my_setenv(char *nam, char *val) { register I32 i=setenv_getix(nam); /* where does it go? */ @@ -1465,8 +1425,7 @@ char *nam, *val; #endif /* WIN32 */ I32 -setenv_getix(nam) -char *nam; +setenv_getix(char *nam) { register I32 i, len = strlen(nam); @@ -1754,12 +1713,10 @@ VTOH(vtohl,long) /* VMS' my_popen() is in VMS.c, same with OS/2. */ #if (!defined(DOSISH) || defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) PerlIO * -my_popen(cmd,mode) -char *cmd; -char *mode; +my_popen(char *cmd, char *mode) { int p[2]; - register I32 this, that; + register I32 This, that; register I32 pid; SV *sv; I32 doexec = strNE(cmd,"-"); @@ -1771,15 +1728,15 @@ char *mode; #endif if (pipe(p) < 0) return Nullfp; - this = (*mode == 'w'); - that = !this; + This = (*mode == 'w'); + that = !This; if (doexec && tainting) { taint_env(); taint_proper("Insecure %s%s", "EXEC"); } while ((pid = (doexec?vfork():fork())) < 0) { if (errno != EAGAIN) { - close(p[this]); + close(p[This]); if (!doexec) croak("Can't fork"); return Nullfp; @@ -1790,7 +1747,7 @@ char *mode; GV* tmpgv; #define THIS that -#define THAT this +#define THAT This close(p[THAT]); if (p[THIS] != (*mode == 'r')) { dup2(p[THIS], *mode == 'r'); @@ -1820,16 +1777,16 @@ char *mode; } do_execfree(); /* free any memory malloced by child on vfork */ close(p[that]); - if (p[that] < p[this]) { - dup2(p[this], p[that]); - close(p[this]); - p[this] = p[that]; + if (p[that] < p[This]) { + dup2(p[This], p[that]); + close(p[This]); + p[This] = p[that]; } - sv = *av_fetch(fdpid,p[this],TRUE); + sv = *av_fetch(fdpid,p[This],TRUE); (void)SvUPGRADE(sv,SVt_IV); SvIVX(sv) = pid; forkprocess = pid; - return PerlIO_fdopen(p[this], mode); + return PerlIO_fdopen(p[This], mode); } #else #if defined(atarist) || defined(DJGPP) @@ -1903,9 +1860,7 @@ int newfd; #ifdef HAS_SIGACTION Sighandler_t -rsignal(signo, handler) -int signo; -Sighandler_t handler; +rsignal(int signo, Sighandler_t handler) { struct sigaction act, oact; @@ -1922,8 +1877,7 @@ Sighandler_t handler; } Sighandler_t -rsignal_state(signo) -int signo; +rsignal_state(int signo) { struct sigaction oact; @@ -1934,10 +1888,7 @@ int signo; } int -rsignal_save(signo, handler, save) -int signo; -Sighandler_t handler; -Sigsave_t *save; +rsignal_save(int signo, Sighandler_t handler, Sigsave_t *save) { struct sigaction act; @@ -1951,9 +1902,7 @@ Sigsave_t *save; } int -rsignal_restore(signo, save) -int signo; -Sigsave_t *save; +rsignal_restore(int signo, Sigsave_t *save) { return sigaction(signo, save, (struct sigaction *)NULL); } @@ -2015,8 +1964,7 @@ Sigsave_t *save; /* VMS' my_pclose() is in VMS.c; same with OS/2 */ #if (!defined(DOSISH) || defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) I32 -my_pclose(ptr) -PerlIO *ptr; +my_pclose(FILE *ptr) { Sigsave_t hstat, istat, qstat; int status; @@ -2065,10 +2013,7 @@ PerlIO *ptr; #if !defined(DOSISH) || defined(OS2) I32 -wait4pid(pid,statusp,flags) -int pid; -int *statusp; -int flags; +wait4pid(int pid, int *statusp, int flags) { SV *sv; SV** svp; @@ -2128,9 +2073,7 @@ int flags; void /*SUPPRESS 590*/ -pidgone(pid,status) -int pid; -int status; +pidgone(int pid, int status) { register SV *sv; char spid[TYPE_CHARS(int)]; @@ -2163,11 +2106,7 @@ PerlIO *ptr; #endif void -repeatcpy(to,from,len,count) -register char *to; -register char *from; -I32 len; -register I32 count; +repeatcpy(register char *to, register char *from, I32 len, register I32 count) { register I32 todo; register char *frombase = from; @@ -2301,10 +2240,7 @@ char *b; #endif /* !HAS_RENAME */ UV -scan_oct(start, len, retlen) -char *start; -I32 len; -I32 *retlen; +scan_oct(char *start, I32 len, I32 *retlen) { register char *s = start; register UV retval = 0; @@ -2326,10 +2262,7 @@ I32 *retlen; } UV -scan_hex(start, len, retlen) -char *start; -I32 len; -I32 *retlen; +scan_hex(char *start, I32 len, I32 *retlen) { register char *s = start; register UV retval = 0; @@ -2441,8 +2374,7 @@ getTHR _((void)) #endif /* OLD_PTHREADS_API */ MAGIC * -condpair_magic(sv) -SV *sv; +condpair_magic(SV *sv) { MAGIC *mg; @@ -2487,7 +2419,7 @@ SV *sv; * Needed for SunOS with Sun's 'acc' for example. */ double -Perl_huge() +Perl_huge(void) { return HUGE_VAL; } |