X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fstr.h;h=db961959c45205b3a63da19ca773e01c544b121f;hb=0ef6ac022673935ef842a1059aad45b89d59f025;hp=9b90cf60f93695e4e6715b2b0d82e782905f3ab4;hpb=b321086267ad1014dc5d09886396cde30f094437;p=pspp diff --git a/src/str.h b/src/str.h index 9b90cf60f9..db961959c4 100644 --- a/src/str.h +++ b/src/str.h @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #if !str_h #define str_h 1 @@ -24,37 +24,22 @@ #include #include - -#if STDC_HEADERS - #include -#else - #ifndef HAVE_STRCHR - #define strchr index - #define strrchr rindex - #endif - - char *strchr (), *strrchr (); +#include + +#include "memmem.h" +#include "snprintf.h" +#include "stpcpy.h" +#include "strcase.h" +#include "strftime.h" +#include "strstr.h" +#include "strtok_r.h" +#include "vsnprintf.h" + +#ifndef HAVE_STRCHR +#define strchr index #endif - -#if !HAVE_STRTOK_R - char *strtok_r (char *, const char *, char **); -#endif - -#if !HAVE_STPCPY - char *stpcpy (char *dest, const char *src); -#endif - -#if !HAVE_STRCASECMP - int strcasecmp (const char *s1, const char *s2); -#endif - -#if !HAVE_STRNCASECMP - int strncasecmp (const char *s1, const char *s2, size_t n); -#endif - -#if !HAVE_MEMMEM - void *memmem (const void *haystack, size_t haystack_len, - const void *needle, size_t needle_len); +#ifndef HAVE_STRRCHR +#define strrchr rindex #endif /* sprintf() wrapper functions for convenience. */ @@ -107,69 +92,66 @@ int nvsprintf (char *buf, const char *format, va_list args); #endif /* Not good sprintf(). */ #endif /* Not GNU C. */ - -#if !HAVE_GETLINE -long getline (char **lineptr, size_t *n, FILE *stream); -#endif - -#if !HAVE_GETDELIM -long getdelim (char **lineptr, size_t * n, int delimiter, FILE * stream); -#endif /* Miscellaneous. */ -void mm_reverse (void *, size_t); -char *mm_find_reverse (const char *, size_t, const char *, size_t); - -int st_compare_pad (const char *, size_t, const char *, size_t); -char *st_spaces (int); -void st_bare_pad_copy (char *dest, const char *src, size_t n); -void st_bare_pad_len_copy (char *dest, const char *src, size_t n, size_t len); -void st_pad_copy (char *dest, const char *src, size_t n); +void buf_reverse (char *, size_t); +char *buf_find_reverse (const char *, size_t, const char *, size_t); +int buf_compare_case (const char *, const char *, size_t); +int buf_compare_rpad (const char *, size_t, const char *, size_t); +void buf_copy_rpad (char *, size_t, const char *, size_t); +void buf_copy_str_lpad (char *, size_t, const char *); +void buf_copy_str_rpad (char *, size_t, const char *); + +int str_compare_rpad (const char *, const char *); +void str_copy_rpad (char *, size_t, const char *); +void str_copy_trunc (char *, size_t, const char *); +void str_copy_buf_trunc (char *, size_t, const char *, size_t); +void str_uppercase (char *); -/* Lengthed strings. */ -struct len_string +/* Fixed-length strings. */ +struct fixed_string { char *string; size_t length; }; -void ls_create (struct len_string *, const char *); -void ls_create_buffer (struct len_string *, +void ls_create (struct fixed_string *, const char *); +void ls_create_buffer (struct fixed_string *, const char *, size_t len); -void ls_init (struct len_string *, const char *, size_t); -void ls_shallow_copy (struct len_string *, const struct len_string *); -void ls_destroy (struct len_string *); +void ls_init (struct fixed_string *, const char *, size_t); +void ls_shallow_copy (struct fixed_string *, const struct fixed_string *); +void ls_destroy (struct fixed_string *); -void ls_null (struct len_string *); -int ls_null_p (const struct len_string *); -int ls_empty_p (const struct len_string *); +void ls_null (struct fixed_string *); +int ls_null_p (const struct fixed_string *); +int ls_empty_p (const struct fixed_string *); -size_t ls_length (const struct len_string *); -char *ls_c_str (const struct len_string *); -char *ls_end (const struct len_string *); +size_t ls_length (const struct fixed_string *); +char *ls_c_str (const struct fixed_string *); +char *ls_end (const struct fixed_string *); #if __GNUC__ > 1 extern inline size_t -ls_length (const struct len_string *st) +ls_length (const struct fixed_string *st) { return st->length; } extern inline char * -ls_c_str (const struct len_string *st) +ls_c_str (const struct fixed_string *st) { return st->string; } extern inline char * -ls_end (const struct len_string *st) +ls_end (const struct fixed_string *st) { return st->string + st->length; } #endif -/* Dynamic strings. */ +/* Variable length strings. */ struct string {