-const char miscutil_rcs[] = "$Id: miscutil.c,v 1.62 2008/12/04 18:16:41 fabiankeil Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 1.66 2011/05/22 10:26:45 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $
*
- * Purpose : zalloc, hash_string, safe_strerror, strcmpic,
- * strncmpic, chomp, and MinGW32 strdup
- * functions.
- * These are each too small to deserve their own file
- * but don't really fit in any other file.
+ * Purpose : zalloc, hash_string, strcmpic, strncmpic, and
+ * MinGW32 strdup functions. These are each too small
+ * to deserve their own file but don't really fit in
+ * any other file.
*
- * Copyright : Written by and Copyright (C) 2001-2007
- * the SourceForge Privoxy team. http://www.privoxy.org/
+ * Copyright : Written by and Copyright (C) 2001-2011 the
+ * Privoxy team. http://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
* by and Copyright (C) 1997 Anonymous Coders and
}
-#ifdef __MINGW32__
-/*********************************************************************
- *
- * Function : strdup
- *
- * Description : For some reason (which is beyond me), gcc and WIN32
- * don't like strdup. When a "free" is executed on a
- * strdup'd ptr, it can at times freez up! So I just
- * replaced it and problem was solved.
- *
- * Parameters :
- * 1 : s = string to duplicate
- *
- * Returns : Pointer to newly malloc'ed copy of the string.
- *
- *********************************************************************/
-char *strdup( const char *s )
-{
- char * result = (char *)malloc( strlen(s)+1 );
-
- if (result != NULL)
- {
- strcpy( result, s );
- }
-
- return( result );
-}
-
-#endif /* def __MINGW32__ */
-
-
-
-/*********************************************************************
- *
- * Function : safe_strerror
- *
- * Description : Variant of the library routine strerror() which will
- * work on systems without the library routine, and
- * which should never return NULL.
- *
- * Parameters :
- * 1 : err = the `errno' of the last operation.
- *
- * Returns : An "English" string of the last `errno'. Allocated
- * with strdup(), so caller frees. May be NULL if the
- * system is out of memory.
- *
- *********************************************************************/
-char *safe_strerror(int err)
-{
- char *s = NULL;
- char buf[BUFFER_SIZE];
-
-
-#ifdef HAVE_STRERROR
- s = strerror(err);
-#endif /* HAVE_STRERROR */
-
- if (s == NULL)
- {
- snprintf(buf, sizeof(buf), "(errno = %d)", err);
- s = buf;
- }
-
- return(strdup(s));
-
-}
-
-
/*********************************************************************
*
* Function : strcmpic
*
* Function : strncmpic
*
- * Description : Case insensitive string comparison (upto n characters)
+ * Description : Case insensitive string comparison (up to n characters)
*
* Parameters :
* 1 : s1 = string 1 to compare
strlcpy(path, dir, path_size);
}
+ assert(NULL != path);
#if defined(_WIN32) || defined(__OS2__)
if(path[strlen(path)-1] != '\\')
{
#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE)
/* keep the entire format string unchanged */
str_arg = starting_p; str_arg_l = p - starting_p;
- /* well, not exactly so for Linux, which does something inbetween,
+ /* well, not exactly so for Linux, which does something between,
* and I don't feel an urge to imitate it: "%+++++hy" -> "%+y" */
#else
/* discard the unrecognized conversion, just keep *