Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lua/lstrlib.c
/* | /* | ||||
** $Id: lstrlib.c,v 1.178.1.1 2013/04/12 18:48:47 roberto Exp $ | ** $Id: lstrlib.c,v 1.178.1.1 2013/04/12 18:48:47 roberto Exp $ | ||||
** Standard library for string operations and pattern-matching | ** Standard library for string operations and pattern-matching | ||||
** See Copyright Notice in lua.h | ** See Copyright Notice in lua.h | ||||
*/ | */ | ||||
#include <sys/ctype.h> | #include <sys/ctype.h> | ||||
#include <sys/zfs_context.h> | #include <sys/zfs_context.h> | ||||
#if defined(__FreeBSD__) | |||||
#include <ctype.h> | |||||
#endif | |||||
#define lstrlib_c | #define lstrlib_c | ||||
#define LUA_LIB | #define LUA_LIB | ||||
#include "lua.h" | #include "lua.h" | ||||
#include "lauxlib.h" | #include "lauxlib.h" | ||||
#include "lualib.h" | #include "lualib.h" | ||||
Show All 9 Lines | |||||
/* macro to `unsign' a character */ | /* macro to `unsign' a character */ | ||||
#define uchar(c) ((unsigned char)(c)) | #define uchar(c) ((unsigned char)(c)) | ||||
/* | /* | ||||
* PATCHED: add missing character macros. | * PATCHED: add missing character macros. | ||||
*/ | */ | ||||
#if !defined(__FreeBSD__) | |||||
#ifdef illumos | #ifdef illumos | ||||
#define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C)) | #define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C)) | ||||
#define toupper(C) (((C) >= 'a' && (C) <= 'z') ? (C) - 'a' + 'A': (C)) | #define toupper(C) (((C) >= 'a' && (C) <= 'z') ? (C) - 'a' + 'A': (C)) | ||||
#define iscntrl(C) ((((C) >= 0) && ((C) <= 0x1f)) || ((C) == 0x7f)) | #define iscntrl(C) ((((C) >= 0) && ((C) <= 0x1f)) || ((C) == 0x7f)) | ||||
#else | #else | ||||
#define isalnum(C) (isalpha(C) || isdigit(C)) | #define isalnum(C) (isalpha(C) || isdigit(C)) | ||||
#define iscntrl(C) (uchar(C) <= 0x1f || uchar(C) == 0x7f) | #define iscntrl(C) (uchar(C) <= 0x1f || uchar(C) == 0x7f) | ||||
#endif | #endif | ||||
#define isgraph(C) ((C) >= 0x21 && (C) <= 0x7E) | #define isgraph(C) ((C) >= 0x21 && (C) <= 0x7E) | ||||
#define ispunct(C) (((C) >= 0x21 && (C) <= 0x2F) || \ | #define ispunct(C) (((C) >= 0x21 && (C) <= 0x2F) || \ | ||||
((C) >= 0x3A && (C) <= 0x40) || \ | ((C) >= 0x3A && (C) <= 0x40) || \ | ||||
((C) >= 0x5B && (C) <= 0x60) || \ | ((C) >= 0x5B && (C) <= 0x60) || \ | ||||
((C) >= 0x7B && (C) <= 0x7E)) | ((C) >= 0x7B && (C) <= 0x7E)) | ||||
#endif | |||||
/* | /* | ||||
* The provided version of sprintf returns a char *, but str_format expects | * The provided version of sprintf returns a char *, but str_format expects | ||||
* it to return the number of characters printed. This version has the expected | * it to return the number of characters printed. This version has the expected | ||||
* behavior. | * behavior. | ||||
*/ | */ | ||||
static size_t str_sprintf(char *buf, const char *fmt, ...) { | static size_t str_sprintf(char *buf, const char *fmt, ...) { | ||||
va_list args; | va_list args; | ||||
▲ Show 20 Lines • Show All 995 Lines • Show Last 20 Lines |