2008-04-14 15:55:36 +01:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* Copyright 2008 VMware, Inc.
|
2008-04-14 15:55:36 +01:00
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
2008-04-14 15:55:36 +01:00
|
|
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Platform independent functions for string manipulation.
|
2008-08-07 09:12:55 +01:00
|
|
|
*
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* @author Jose Fonseca <jfonseca@vmware.com>
|
2008-04-14 15:55:36 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef U_STRING_H_
|
|
|
|
#define U_STRING_H_
|
|
|
|
|
2015-07-22 13:21:24 +01:00
|
|
|
#if !defined(XF86_LIBC_H)
|
2008-04-14 15:55:36 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2017-10-02 23:33:46 +01:00
|
|
|
#include <stdlib.h>
|
2008-04-14 15:55:36 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdarg.h>
|
2017-10-03 20:56:01 +01:00
|
|
|
#include <string.h>
|
2021-02-18 16:20:22 +00:00
|
|
|
#include <limits.h>
|
2008-04-14 15:55:36 +01:00
|
|
|
|
2015-07-22 13:21:24 +01:00
|
|
|
#include "util/macros.h" // PRINTFLIKE
|
2008-05-05 15:58:37 +01:00
|
|
|
|
2008-04-14 15:55:36 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-08-30 07:56:17 +01:00
|
|
|
#if !defined(_GNU_SOURCE) || defined(__APPLE__)
|
2011-11-25 13:37:07 +00:00
|
|
|
|
2018-11-20 11:24:55 +00:00
|
|
|
#define strchrnul util_strchrnul
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline char *
|
2011-11-25 13:37:07 +00:00
|
|
|
util_strchrnul(const char *s, char c)
|
|
|
|
{
|
|
|
|
for (; *s && *s != c; ++s);
|
|
|
|
|
|
|
|
return (char *)s;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2008-08-07 09:12:55 +01:00
|
|
|
|
2015-07-22 13:21:24 +01:00
|
|
|
#ifdef _WIN32
|
2008-08-07 09:12:55 +01:00
|
|
|
|
2018-11-20 11:55:00 +00:00
|
|
|
#define sprintf util_sprintf
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void
|
2015-07-22 13:21:24 +01:00
|
|
|
PRINTFLIKE(2, 3)
|
2008-05-05 15:58:37 +01:00
|
|
|
util_sprintf(char *str, const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
2021-02-18 16:20:22 +00:00
|
|
|
vsnprintf(str, INT_MAX, format, ap);
|
2008-05-05 15:58:37 +01:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
2018-11-20 11:55:55 +00:00
|
|
|
#define vasprintf util_vasprintf
|
2017-09-08 23:41:16 +01:00
|
|
|
static inline int
|
|
|
|
util_vasprintf(char **ret, const char *format, va_list ap)
|
|
|
|
{
|
|
|
|
va_list ap_copy;
|
|
|
|
|
|
|
|
/* Compute length of output string first */
|
|
|
|
va_copy(ap_copy, ap);
|
2018-11-20 12:02:36 +00:00
|
|
|
int r = vsnprintf(NULL, 0, format, ap_copy);
|
2017-09-08 23:41:16 +01:00
|
|
|
va_end(ap_copy);
|
|
|
|
|
|
|
|
if (r < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*ret = (char *) malloc(r + 1);
|
2018-09-06 15:43:53 +01:00
|
|
|
if (!*ret)
|
2017-09-08 23:41:16 +01:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Print to buffer */
|
2018-11-20 12:02:36 +00:00
|
|
|
return vsnprintf(*ret, r + 1, format, ap);
|
2017-09-08 23:41:16 +01:00
|
|
|
}
|
|
|
|
|
2019-07-19 22:09:34 +01:00
|
|
|
#define asprintf util_asprintf
|
2019-07-23 10:52:16 +01:00
|
|
|
static inline int
|
|
|
|
util_asprintf(char **str, const char *fmt, ...)
|
2019-07-19 22:09:34 +01:00
|
|
|
{
|
2019-07-23 10:52:16 +01:00
|
|
|
int ret;
|
2019-07-19 22:09:34 +01:00
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
2019-07-23 10:52:16 +01:00
|
|
|
ret = vasprintf(str, fmt, args);
|
2019-07-19 22:09:34 +01:00
|
|
|
va_end(args);
|
2019-07-23 10:52:16 +01:00
|
|
|
return ret;
|
2019-07-19 22:09:34 +01:00
|
|
|
}
|
2008-05-05 15:58:37 +01:00
|
|
|
|
2019-08-27 11:53:00 +01:00
|
|
|
#ifndef strcasecmp
|
2018-11-20 11:39:28 +00:00
|
|
|
#define strcasecmp stricmp
|
2019-08-27 11:53:00 +01:00
|
|
|
#endif
|
|
|
|
|
2018-11-20 11:42:14 +00:00
|
|
|
#define strdup _strdup
|
2015-09-01 23:29:17 +01:00
|
|
|
|
2018-09-10 18:26:26 +01:00
|
|
|
#if defined(_WIN32) && !defined(HAVE_STRTOK_R)
|
|
|
|
#define strtok_r strtok_s
|
|
|
|
#endif
|
|
|
|
|
2008-04-14 15:55:36 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* U_STRING_H_ */
|