Fix documentation bugs. Use (void) var in bsafe.c for unused variables.

This commit is contained in:
Paul Hsieh 2015-04-16 00:04:38 -07:00
parent 0013d10cbd
commit ee21a6e839
4 changed files with 1119 additions and 1112 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2014, websnarf
Copyright (c) 2014, Paul Hsieh
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -1,27 +1,34 @@
The Better String Library
The Better String Library is an abstraction of a string data type which is superior to the C library char buffer
string type, or C++'s std::string. Among the features achieved are:
The Better String Library is an abstraction of a string data type which is
superior to the C library char buffer string type, or C++'s std::string.
Among the features achieved are:
Substantial mitigation of buffer overflow/overrun problems and other failures that result from erroneous usage
of the common C string library functions
Substantial mitigation of buffer overflow/overrun problems and other
failures that result from erroneous usage of the common C string
library functions
Significantly simplified string manipulation
High performance interoperability with other source/libraries which expect '\0' terminated char buffers
High performance interoperability with other source/libraries which
expect '\0' terminated char buffers
Improved overall performance of common string operations
Functional equivalency with other more modern languages
The library is totally stand alone, portable (known to work with gcc/g++, MSVC++, Intel C++, WATCOM C/C++, Turbo C,
Borland C++, IBM's native CC compiler on Windows, Linux and Mac OS X), high performance, easy to use and is not part
of some other collection of data structures. Even the file I/O functions are totally abstracted (so that other
stream-like mechanisms, like sockets, can be used.) Nevertheless, it is adequate as a complete replacement of the C
string library for string manipulation in any C program.
The library is totally stand alone, portable (known to work with gcc/g++,
MSVC++, Intel C++, WATCOM C/C++, Turbo C, Borland C++, IBM's native CC
compiler on Windows, Linux and Mac OS X), high performance, easy to use and
is not part of some other collection of data structures. Even the file I/O
functions are totally abstracted (so that other stream-like mechanisms, like
sockets, can be used.) Nevertheless, it is adequate as a complete
replacement of the C string library for string manipulation in any C program.
The library includes a robust C++ wrapper that uses overloaded operators, rich constructors, exceptions, stream I/O
and STL to make the CBString struct a natural and powerful string abstraction with more functionality and higher
performance than std::string.
The library includes a robust C++ wrapper that uses overloaded operators,
rich constructors, exceptions, stream I/O and STL to make the CBString
struct a natural and powerful string abstraction with more functionality and
higher performance than std::string.
Bstrlib is stable, well tested and suitable for any software production environment.
Bstrlib is stable, well tested and suitable for any software production
environment.

28
bsafe.c
View File

@ -24,16 +24,16 @@ char * strcpy (char *dst, const char *src);
char * strcat (char *dst, const char *src);
char * strcpy (char *dst, const char *src) {
dst = dst;
src = src;
(void) dst;
(void) src;
fprintf (stderr, "bsafe error: strcpy() is not safe, use bstrcpy instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
}
char * strcat (char *dst, const char *src) {
dst = dst;
src = src;
(void) dst;
(void) src;
fprintf (stderr, "bsafe error: strcat() is not safe, use bstrcat instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
@ -41,7 +41,7 @@ char * strcat (char *dst, const char *src) {
#if !defined (__GNUC__) && (!defined(_MSC_VER) || (_MSC_VER <= 1310))
char * (gets) (char * buf) {
buf = buf;
(void) buf;
fprintf (stderr, "bsafe error: gets() is not safe, use bgets.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
@ -49,33 +49,33 @@ char * (gets) (char * buf) {
#endif
char * (strncpy) (char *dst, const char *src, size_t n) {
dst = dst;
src = src;
n = n;
(void) dst;
(void) src;
(void) n;
fprintf (stderr, "bsafe error: strncpy() is not safe, use bmidstr instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
}
char * (strncat) (char *dst, const char *src, size_t n) {
dst = dst;
src = src;
n = n;
(void) dst;
(void) src;
(void) n;
fprintf (stderr, "bsafe error: strncat() is not safe, use bstrcat then btrunc\n\tor cstr2tbstr, btrunc then bstrcat instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
}
char * (strtok) (char *s1, const char *s2) {
s1 = s1;
s2 = s2;
(void) s1;
(void) s2;
fprintf (stderr, "bsafe error: strtok() is not safe, use bsplit or bsplits instead.\n");
if (bsafeShouldExit) exit (-1);
return NULL;
}
char * (strdup) (const char *s) {
s = s;
(void) s;
fprintf (stderr, "bsafe error: strdup() is not safe, use bstrcpy.\n");
if (bsafeShouldExit) exit (-1);
return NULL;

File diff suppressed because it is too large Load Diff