This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
bump $VERSION for Porting/Maintainers.pm to placate cmp_version.t
[perl5.git] / x2p / util.c
index 20444de..464dd8f 100644 (file)
@@ -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 */
 
@@ -34,7 +32,7 @@ safemalloc(MEM_SIZE size)
        fprintf(stderr,"0x%lx: (%05d) malloc %ld bytes\n",(unsigned long)ptr,
                an++,(long)size);
 #endif
-    if (ptr != Nullch)
+    if (ptr != NULL)
        return ptr;
     else {
        fputs(nomem,stdout) FLUSH;
@@ -59,7 +57,7 @@ saferealloc(Malloc_t where, MEM_SIZE size)
        fprintf(stderr,"0x%lx: (%05d) realloc %ld bytes\n",(unsigned long)ptr,an++,(long)size);
     }
 #endif
-    if (ptr != Nullch)
+    if (ptr != NULL)
        return ptr;
     else {
        fputs(nomem,stdout) FLUSH;
@@ -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 *
@@ -134,29 +119,30 @@ cpy2(register char *to, register char *from, register int delim)
 /* return ptr to little string in big string, NULL if not found */
 
 char *
-instr(char *big, char *little)
+instr(char *big, const char *little)
 {
-    register char *t, *s, *x;
+    register char *t, *x;
+    register const char *s;
 
     for (t = big; *t; t++) {
        for (x=t,s=little; *s; x++,s++) {
            if (!*x)
-               return Nullch;
+               return NULL;
            if (*s != *x)
                break;
        }
        if (!*s)
            return t;
     }
-    return Nullch;
+    return NULL;
 }
 
 /* copy a string to a safe spot */
 
 char *
-savestr(char *str)
+savestr(const 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 +163,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)