1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 14:08:06 +01:00

- Added wstrndup() and WMGetFontName()

This commit is contained in:
dan
2002-12-02 00:01:05 +00:00
parent 96c64e15ef
commit ca43aba088
7 changed files with 721 additions and 688 deletions

View File

@@ -49,6 +49,8 @@ Changes since wmaker 0.80.1:
most once for each font in a fontset (eliminates a possible security exploit) most once for each font in a fontset (eliminates a possible security exploit)
- Fixed WMGetTextDefaultColor() not to retain the returned color. It returns - Fixed WMGetTextDefaultColor() not to retain the returned color. It returns
only a reference to the internal color, which you shouldn't release only a reference to the internal color, which you shouldn't release
- Added wstrndup()
- Added WMGetFontName()
Changes since wmaker 0.80.0: Changes since wmaker 0.80.0:

View File

@@ -764,6 +764,8 @@ WMFont* WMRetainFont(WMFont *font);
void WMReleaseFont(WMFont *font); void WMReleaseFont(WMFont *font);
char* WMGetFontName(WMFont *font);
unsigned int WMFontHeight(WMFont *font); unsigned int WMFontHeight(WMFont *font);
Bool WMIsAntialiasedFont(WMFont *font); Bool WMIsAntialiasedFont(WMFont *font);

View File

@@ -242,6 +242,7 @@ void wrelease(void *ptr);
void* wretain(void *ptr); void* wretain(void *ptr);
char* wstrdup(char *str); char* wstrdup(char *str);
char* wstrndup(char *str, size_t len);
/* Concatenate str1 with str2 and return that in a newly malloc'ed string. /* Concatenate str1 with str2 and return that in a newly malloc'ed string.
* str1 and str2 can be any strings including static and constant strings. * str1 and str2 can be any strings including static and constant strings.

View File

@@ -1,3 +1,5 @@
build
WINGs.c WINGs.c
wings.so wings.so
build *.pyc
*.pyo

View File

@@ -78,8 +78,8 @@
#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) #if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
/* only include stdio.h if we are not re-defining snprintf or vsnprintf */ /* only include stdio.h if we are not re-defining snprintf or vsnprintf */
#include <stdio.h> #include <stdio.h>
/* make the compiler happy with an empty file */ /* make the compiler happy with an empty file */
void dummy_snprintf(void) {} void dummy_snprintf(void) {}
#else #else
#ifdef HAVE_LONG_DOUBLE #ifdef HAVE_LONG_DOUBLE
@@ -749,14 +749,14 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
} }
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
int vsnprintf (char *str, size_t count, const char *fmt, va_list args) int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
{ {
return dopr(str, count, fmt, args); return dopr(str, count, fmt, args);
} }
#endif #endif
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) #if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
int snprintf(char *str,size_t count,const char *fmt,...) int snprintf(char *str,size_t count,const char *fmt,...)
{ {
size_t ret; size_t ret;
va_list ap; va_list ap;
@@ -771,7 +771,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
#endif #endif
#ifndef HAVE_VASPRINTF #ifndef HAVE_VASPRINTF
int vasprintf(char **ptr, const char *format, va_list ap) int vasprintf(char **ptr, const char *format, va_list ap)
{ {
int ret; int ret;
@@ -788,7 +788,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
#ifndef HAVE_ASPRINTF #ifndef HAVE_ASPRINTF
int asprintf(char **ptr, const char *format, ...) int asprintf(char **ptr, const char *format, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
@@ -803,9 +803,9 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
#ifdef TEST_SNPRINTF #ifdef TEST_SNPRINTF
int sprintf(char *str,const char *fmt,...); int sprintf(char *str,const char *fmt,...);
int main (void) int main (void)
{ {
char buf1[1024]; char buf1[1024];
char buf2[1024]; char buf2[1024];

View File

@@ -186,6 +186,21 @@ wstrdup(char *str)
} }
char*
wstrndup(char *str, size_t len)
{
char *copy;
assert(str!=NULL);
len = WMIN(len, strlen(str));
copy = strncpy(wmalloc(len+1), str, len);
copy[len] = 0;
return copy;
}
char* char*
wstrconcat(char *str1, char *str2) wstrconcat(char *str1, char *str2)
{ {

View File

@@ -529,6 +529,8 @@ WMIsAntialiasingEnabled(WMScreen *scrPtr)
Bool Bool
WMIsAntialiasedFont(WMFont *font) WMIsAntialiasedFont(WMFont *font)
{ {
wassertrv(font!=NULL, False);
return font->antialiased; return font->antialiased;
} }
@@ -542,6 +544,15 @@ WMFontHeight(WMFont *font)
} }
char*
WMGetFontName(WMFont *font)
{
wassertrv(font!=NULL, NULL);
return font->name;
}
WMFont* WMFont*
WMDefaultSystemFont(WMScreen *scrPtr) WMDefaultSystemFont(WMScreen *scrPtr)
{ {