diff options
author | Andy Lester <andy@petdance.com> | 2005-11-04 09:13:55 -0600 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-11-07 12:26:29 +0000 |
commit | 8665f9e443dd7c1aaeda99d470ddf0b6fe056f80 (patch) | |
tree | 1942b919ad725753da59c9de63d1901bf6299f94 /x2p | |
parent | f43a9a3142f71956ec256aa7b03ca89db65cbb0c (diff) | |
download | perl-8665f9e443dd7c1aaeda99d470ddf0b6fe056f80.tar.gz |
Cleaning up x2p directory
Message-ID: <20051104211355.GB12651@petdance.com>
p4raw-id: //depot/perl@26033
Diffstat (limited to 'x2p')
-rw-r--r-- | x2p/EXTERN.h | 4 | ||||
-rw-r--r-- | x2p/INTERN.h | 4 | ||||
-rw-r--r-- | x2p/a2p.h | 8 | ||||
-rw-r--r-- | x2p/a2py.c | 4 | ||||
-rw-r--r-- | x2p/hash.c | 91 | ||||
-rw-r--r-- | x2p/hash.h | 14 | ||||
-rw-r--r-- | x2p/proto.h | 8 | ||||
-rw-r--r-- | x2p/str.c | 188 | ||||
-rw-r--r-- | x2p/str.h | 15 | ||||
-rw-r--r-- | x2p/util.c | 38 | ||||
-rw-r--r-- | x2p/util.h | 9 | ||||
-rw-r--r-- | x2p/walk.c | 9 |
12 files changed, 22 insertions, 370 deletions
diff --git a/x2p/EXTERN.h b/x2p/EXTERN.h index 59eb166ad0..c82736e5fc 100644 --- a/x2p/EXTERN.h +++ b/x2p/EXTERN.h @@ -1,11 +1,9 @@ -/* $RCSfile: EXTERN.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:05 $ +/* EXTERN.h * * Copyright (C) 1991, 1992, 1993, 1994, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: EXTERN.h,v $ */ #undef EXT diff --git a/x2p/INTERN.h b/x2p/INTERN.h index d1dcd06fb9..539e915069 100644 --- a/x2p/INTERN.h +++ b/x2p/INTERN.h @@ -1,11 +1,9 @@ -/* $RCSfile: INTERN.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:06 $ +/* INTERN.h * * Copyright (C) 1993, 1994, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: INTERN.h,v $ */ #undef EXT @@ -1,12 +1,10 @@ -/* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $ +/* a2p.h * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, * 2000, 2001, 2002, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: a2p.h,v $ */ #define VOIDUSED 1 @@ -363,11 +361,7 @@ typedef struct htbl HASH; EXT char *Yes INIT("1"); EXT char *No INIT(""); -#define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 ))) - -#define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%"NVgf")",Str->str_nval),buf) : "" ))) #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) -#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str))) EXT STR *Str; #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) diff --git a/x2p/a2py.c b/x2p/a2py.c index 1c7fd0ac96..df0a55cb21 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -1,12 +1,10 @@ -/* $RCSfile: a2py.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:14 $ +/* a2py.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, * 2000, 2001, 2002, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: a2py.c,v $ */ #if defined(OS2) || defined(WIN32) || defined(NETWARE) diff --git a/x2p/hash.c b/x2p/hash.c index 07936f8c4e..8c218b69e5 100644 --- a/x2p/hash.c +++ b/x2p/hash.c @@ -1,12 +1,10 @@ -/* $RCSfile: hash.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:20 $ +/* hash.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002, - * by Larry Wall and others + * 2005 by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: hash.c,v $ */ #include <stdio.h> @@ -92,48 +90,10 @@ hstore(register HASH *tb, char *key, STR *val) return FALSE; } -#ifdef NOTUSED -bool -hdelete(register HASH *tb, char *key) -{ - register char *s; - register int i; - register int hash; - register HENT *entry; - register HENT **oentry; - - if (!tb) - return FALSE; - for (s=key, i=0, hash = 0; - /* while */ *s; - s++, i++, hash *= 5) { - hash += *s * coeff[i]; - } - - oentry = &(tb->tbl_array[hash & tb->tbl_max]); - entry = *oentry; - i = 1; - for (; entry; i=0, oentry = &entry->hent_next, entry = entry->hent_next) { - if (entry->hent_hash != hash) /* strings can't be equal */ - continue; - if (strNE(entry->hent_key,key)) /* is this it? */ - continue; - safefree((char*)entry->hent_val); - safefree(entry->hent_key); - *oentry = entry->hent_next; - safefree((char*)entry); - if (i) - tb->tbl_fill--; - return TRUE; - } - return FALSE; -} -#endif - void hsplit(HASH *tb) { - int oldsize = tb->tbl_max + 1; + const int oldsize = tb->tbl_max + 1; register int newsize = oldsize * 2; register int i; register HENT **a; @@ -180,16 +140,6 @@ hnew(void) return tb; } -#ifdef NOTUSED -hshow(register HASH *tb) -{ - fprintf(stderr,"%5d %4d (%2d%%)\n", - tb->tbl_max+1, - tb->tbl_fill, - tb->tbl_fill * 100 / (tb->tbl_max+1)); -} -#endif - int hiterinit(register HASH *tb) { @@ -197,38 +147,3 @@ hiterinit(register HASH *tb) tb->tbl_eiter = Null(HENT*); return tb->tbl_fill; } - -HENT * -hiternext(register HASH *tb) -{ - register HENT *entry; - - entry = tb->tbl_eiter; - do { - if (entry) - entry = entry->hent_next; - if (!entry) { - tb->tbl_riter++; - if (tb->tbl_riter > tb->tbl_max) { - tb->tbl_riter = -1; - break; - } - entry = tb->tbl_array[tb->tbl_riter]; - } - } while (!entry); - - tb->tbl_eiter = entry; - return entry; -} - -char * -hiterkey(register HENT *entry) -{ - return entry->hent_key; -} - -STR * -hiterval(register HENT *entry) -{ - return entry->hent_val; -} diff --git a/x2p/hash.h b/x2p/hash.h index bcab1ef4d5..9f9c6d5ff9 100644 --- a/x2p/hash.h +++ b/x2p/hash.h @@ -1,18 +1,16 @@ -/* $RCSfile: hash.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:21 $ +/* hash.h * - * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2000, + * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2005 * by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: hash.h,v $ */ #define FILLPCT 60 /* don't make greater than 99 */ #ifdef DOINIT -char coeff[] = { +char const coeff[] = { 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, @@ -22,7 +20,7 @@ char coeff[] = { 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1}; #else -extern char coeff[]; +extern const char coeff[]; #endif typedef struct hentry HENT; @@ -42,12 +40,8 @@ struct htbl { HENT *tbl_eiter; /* current entry of iterator */ }; -bool hdelete (HASH *tb, char *key); STR * hfetch ( HASH *tb, char *key ); int hiterinit ( HASH *tb ); -char * hiterkey ( HENT *entry ); -HENT * hiternext ( HASH *tb ); -STR * hiterval ( HENT *entry ); HASH * hnew ( void ); void hsplit ( HASH *tb ); bool hstore ( HASH *tb, char *key, STR *val ); diff --git a/x2p/proto.h b/x2p/proto.h deleted file mode 100644 index 28c3b8c537..0000000000 --- a/x2p/proto.h +++ /dev/null @@ -1,8 +0,0 @@ -/* proto.h - * - * Copyright (C) 1991, 1996, by Larry Wall - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the README file. - * - */ @@ -1,12 +1,10 @@ -/* $RCSfile: str.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:26 $ +/* str.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, - * 2001, 2002, by Larry Wall and others + * 2001, 2002, 2005 by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: str.c,v $ */ #include "EXTERN.h" @@ -44,23 +42,6 @@ str_2ptr(register STR *str) return str->str_ptr; } -double -str_2num(register STR *str) -{ - if (!str) - return 0.0; - if (str->str_len && str->str_pok) - str->str_nval = atof(str->str_ptr); - else - str->str_nval = 0.0; - str->str_nok = 1; -#ifdef DEBUGGING - if (debug & 32) - fprintf(stderr,"0x%lx num(%g)\n",(unsigned long)str,str->str_nval); -#endif - return str->str_nval; -} - void str_sset(STR *dstr, register STR *sstr) { @@ -101,19 +82,6 @@ str_set(register STR *str, register char *ptr) } void -str_chop(register STR *str, register char *ptr) /* like set but assuming ptr is in str */ - - -{ - if (!(str->str_pok)) - str_2ptr(str); - str->str_cur -= (ptr - str->str_ptr); - memcpy(str->str_ptr, ptr, str->str_cur + 1); - str->str_nok = 0; /* invalidate number */ - str->str_pok = 1; /* validate pointer */ -} - -void str_ncat(register STR *str, register char *ptr, register int len) { if (!(str->str_pok)) @@ -152,41 +120,6 @@ str_cat(register STR *str, register char *ptr) str->str_pok = 1; /* validate pointer */ } -char * -str_append_till(register STR *str, register char *from, register int delim, char *keeplist) -{ - register char *to; - register int len; - - if (!from) - return Nullch; - len = strlen(from); - GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1); - str->str_nok = 0; /* invalidate number */ - str->str_pok = 1; /* validate pointer */ - to = str->str_ptr+str->str_cur; - for (; *from; from++,to++) { - if (*from == '\\' && from[1] && delim != '\\') { - if (!keeplist) { - if (from[1] == delim || from[1] == '\\') - from++; - else - *to++ = *from++; - } - else if (strchr(keeplist,from[1])) - *to++ = *from++; - else - from++; - } - else if (*from == delim) - break; - *to = *from; - } - *to = '\0'; - str->str_cur = to - str->str_ptr; - return from; -} - STR * str_new(int len) { @@ -205,29 +138,9 @@ str_new(int len) return str; } -void -str_grow(register STR *str, int len) -{ - if (len && str) - GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); -} - /* make str point to what nstr did */ void -str_replace(register STR *str, register STR *nstr) -{ - safefree(str->str_ptr); - str->str_ptr = nstr->str_ptr; - str->str_len = nstr->str_len; - str->str_cur = nstr->str_cur; - str->str_pok = nstr->str_pok; - if ((str->str_nok = nstr->str_nok)) - str->str_nval = nstr->str_nval; - safefree((char*)nstr); -} - -void str_free(register STR *str) { if (!str) @@ -336,95 +249,6 @@ thats_all_folks: return str->str_cur ? str->str_ptr : Nullch; } -void -str_inc(register STR *str) -{ - register char *d; - - if (!str) - return; - if (str->str_nok) { - str->str_nval += 1.0; - str->str_pok = 0; - return; - } - if (!str->str_pok) { - str->str_nval = 1.0; - str->str_nok = 1; - return; - } - for (d = str->str_ptr; *d && *d != '.'; d++) ; - d--; - if (!isDIGIT(*str->str_ptr) || !isDIGIT(*d) ) { - str_numset(str,atof(str->str_ptr) + 1.0); /* punt */ - return; - } - while (d >= str->str_ptr) { - if (++*d <= '9') - return; - *(d--) = '0'; - } - /* oh,oh, the number grew */ - GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + 2); - str->str_cur++; - for (d = str->str_ptr + str->str_cur; d > str->str_ptr; d--) - *d = d[-1]; - *d = '1'; -} - -void -str_dec(register STR *str) -{ - register char *d; - - if (!str) - return; - if (str->str_nok) { - str->str_nval -= 1.0; - str->str_pok = 0; - return; - } - if (!str->str_pok) { - str->str_nval = -1.0; - str->str_nok = 1; - return; - } - for (d = str->str_ptr; *d && *d != '.'; d++) ; - d--; - if (!isDIGIT(*str->str_ptr) || !isDIGIT(*d) || (*d == '0' && d == str->str_ptr)) { - str_numset(str,atof(str->str_ptr) - 1.0); /* punt */ - return; - } - while (d >= str->str_ptr) { - if (--*d >= '0') - return; - *(d--) = '9'; - } -} - -/* make a string that will exist for the duration of the expression eval */ - -STR * -str_mortal(STR *oldstr) -{ - register STR *str = str_new(0); - static long tmps_size = -1; - - str_sset(str,oldstr); - if (++tmps_max > tmps_size) { - tmps_size = tmps_max; - if (!(tmps_size & 127)) { - if (tmps_size) - tmps_list = (STR**)saferealloc((char*)tmps_list, - (tmps_size + 128) * sizeof(STR*) ); - else - tmps_list = (STR**)safemalloc(128 * sizeof(char*)); - } - } - tmps_list[tmps_max] = str; - return str; -} - STR * str_make(char *s) { @@ -434,11 +258,3 @@ str_make(char *s) return str; } -STR * -str_nmake(double n) -{ - register STR *str = str_new(0); - - str_numset(str,n); - return str; -} @@ -1,12 +1,10 @@ -/* $RCSfile: str.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:27 $ +/* str.h * - * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2000, + * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2005 * by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: str.h,v $ */ struct string { @@ -30,25 +28,16 @@ struct string { EXT STR **tmps_list; EXT long tmps_max INIT(-1); -double str_2num ( STR *str ); char * str_2ptr ( STR *str ); -char * str_append_till ( STR *str, char *from, int delim, char *keeplist ); void str_cat ( STR *str, char *ptr ); -void str_chop ( STR *str, char *ptr ); -void str_dec ( STR *str ); void str_free ( STR *str ); char * str_gets ( STR *str, FILE *fp ); -void str_grow ( STR *str, int len ); -void str_inc ( STR *str ); int str_len ( STR *str ); STR * str_make ( char *s ); -STR * str_mortal ( STR *oldstr ); void str_ncat ( STR *str, char *ptr, int len ); STR * str_new ( int len ); -STR * str_nmake ( double n ); void str_nset ( STR *str, char *ptr, int len ); void str_numset ( STR *str, double num ); -void str_replace ( STR *str, STR *nstr ); void str_scat ( STR *dstr, STR *sstr ); void str_set ( STR *str, char *ptr ); void str_sset ( STR *dstr, STR *sstr ); diff --git a/x2p/util.c b/x2p/util.c index 20444decfc..6994e873f7 100644 --- a/x2p/util.c +++ b/x2p/util.c @@ -1,12 +1,10 @@ -/* $RCSfile: util.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:29 $ +/* util.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, - * 2000, 2001, by Larry Wall and others + * 2000, 2001, 2005 by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: util.c,v $ */ #include "EXTERN.h" @@ -17,7 +15,7 @@ #include <stdarg.h> #define FLUSH -static char nomem[] = "Out of memory!\n"; +static const char nomem[] = "Out of memory!\n"; /* paranoid version of malloc */ @@ -81,19 +79,6 @@ safefree(Malloc_t where) free(where); } -/* safe version of string copy */ - -char * -safecpy(char *to, register char *from, register int len) -{ - register char *dest = to; - - if (from != Nullch) - for (len--; len && (*dest++ = *from++); len--) ; - *dest = '\0'; - return to; -} - /* copy a string up to some (non-backslashed) delimiter, if any */ char * @@ -156,7 +141,7 @@ instr(char *big, char *little) char * savestr(char *str) { - register char *newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1)); + register char * const newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1)); (void)strcpy(newaddr,str); return newaddr; @@ -177,21 +162,6 @@ growstr(char **strptr, int *curlen, int newlen) } void -croak(const char *pat,...) -{ -#if defined(HAS_VPRINTF) - va_list args; - - va_start(args, pat); - vfprintf(stderr,pat,args); - va_end(args); -#else - fprintf(stderr,pat,a1,a2,a3,a4); -#endif - exit(1); -} - -void fatal(const char *pat,...) { #if defined(HAS_VPRINTF) diff --git a/x2p/util.h b/x2p/util.h index 8ca913b9a7..74341c2959 100644 --- a/x2p/util.h +++ b/x2p/util.h @@ -1,12 +1,10 @@ -/* $RCSfile: util.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:30 $ +/* util.h * - * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, + * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2005 * by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: util.h,v $ */ /* is the string for makedir a directory name or a filename? */ @@ -24,14 +22,11 @@ char * cpy2 ( char *to, char *from, int delim ); char * cpytill ( char *to, char *from, int delim ); void growstr ( char **strptr, int *curlen, int newlen ); char * instr ( char *big, char *little ); -char * safecpy ( char *to, char *from, int len ); char * savestr ( char *str ); -void croak ( const char *pat, ... ); void fatal ( const char *pat, ... ); void warn ( const char *pat, ... ); int prewalk ( int numit, int level, int node, int *numericptr ); Malloc_t safemalloc (MEM_SIZE nbytes); -Malloc_t safecalloc (MEM_SIZE elements, MEM_SIZE size); Malloc_t saferealloc (Malloc_t where, MEM_SIZE nbytes); Free_t safefree (Malloc_t where); diff --git a/x2p/walk.c b/x2p/walk.c index 65015ac2e6..de1263fc16 100644 --- a/x2p/walk.c +++ b/x2p/walk.c @@ -1,12 +1,10 @@ -/* $RCSfile: walk.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:31 $ +/* walk.c * * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, * 2000, 2001, 2002, 2005 by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. - * - * $Log: walk.c,v $ */ #include "EXTERN.h" @@ -43,11 +41,6 @@ char *instr(char *big, char *little); STR * walk(int useval, int level, register int node, int *numericptr, int minprec) - - - - - /* minimum precedence without parens */ { register int len; register STR *str; |