summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2013-05-02 08:04:04 -0700
committerAaron Plattner <aplattner@nvidia.com>2013-05-02 08:04:04 -0700
commit3f71f6ae5b985cff6da6a8f083433f369d9ca25f (patch)
tree2ee73f5365e07703fb08012f36e92405108516ca
parente118115f73ff630e341d3ce381eeb2ac1b06547d (diff)
319.17319.17
-rw-r--r--COPYING39
-rw-r--r--common-utils/common-utils.c99
-rw-r--r--common-utils/common-utils.h5
-rw-r--r--version.mk2
4 files changed, 124 insertions, 21 deletions
diff --git a/COPYING b/COPYING
index 5b6e7c6..d159169 100644
--- a/COPYING
+++ b/COPYING
@@ -1,12 +1,12 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
+ Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
+the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
-
- GNU GENERAL PUBLIC LICENSE
+
+ GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
-
+
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
-
+
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
-
+
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -303,10 +303,9 @@ the "copyright" line and a pointer to where the full notice is found.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- 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
-
+ 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.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names:
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
+library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
diff --git a/common-utils/common-utils.c b/common-utils/common-utils.c
index a11d996..7b18294 100644
--- a/common-utils/common-utils.c
+++ b/common-utils/common-utils.c
@@ -319,6 +319,19 @@ char *tilde_expansion(const char *str)
} /* tilde_expansion() */
+/*
+ * nv_prepend_to_string_list() - add a new string to a string list, delimited
+ * by the given string delimiter. The original list is freed.
+ */
+
+char *nv_prepend_to_string_list(char *list, const char *item, const char *delim)
+{
+ char *new_list = nvstrcat(item, list ? delim : NULL, list, NULL);
+ nvfree(list);
+ return new_list;
+}
+
+
/****************************************************************************/
/* TextRows helper functions */
/****************************************************************************/
@@ -693,3 +706,89 @@ char *nvstrchrnul(char *s, int c)
}
return result;
}
+
+
+/****************************************************************************/
+/* string helper functions */
+/****************************************************************************/
+
+/*
+ * nv_trim_space() - remove any leading and trailing whitespace from a string
+ * and return a pointer to the modified string. The original string may be
+ * modified; the returned value should *NOT* be deallocated with free(), since
+ * it may point somewhere other than the beginning of the original string. If
+ * the original string was a malloc()ed buffer, that string should be stored
+ * separately from the returned value of nv_strip_space, and freed.
+ */
+
+char *nv_trim_space(char *string) {
+ char *ret, *end;
+
+ for (ret = string; *ret && isspace(*ret); ret++);
+ for (end = ret + strlen(ret); end >= ret && isspace(*end); end--) {
+ *end = '\0';
+ }
+
+ return ret;
+}
+
+/*
+ * trim_char() - helper function to remove a character from the initial and
+ * final positions of a string, and optionally report how many replacements
+ * were made. The returned value should not be free()d (see nv_trim_space()).
+ */
+
+static char *trim_char(char *string, char trim, int *count) {
+ int len, replaced = 0;
+
+ if (!string || trim == '\0') {
+ return NULL;
+ }
+
+ len = strlen(string);
+
+ if (string[0] == trim) {
+ string++;
+ replaced++;
+ }
+
+ if (string[len - 1] == trim) {
+ string[len - 1] = '\0';
+ replaced++;
+ }
+
+ if (count) {
+ *count = replaced;
+ }
+
+ return string;
+}
+
+/*
+ * nv_trim_char() - remove a character from the initial and final positions of
+ * a string. The returned value should not be free()d (see nv_trim_space()).
+ */
+
+char *nv_trim_char(char *string, char trim) {
+ return trim_char(string, trim, NULL);
+}
+
+/*
+ * nv_trim_char_strict() - remove a character from the initial and final
+ * positions of a string. If no replacements were made, or if replacements were
+ * made at both positions, return the modified string. Otherwise, return NULL.
+ * The returned value should not be free()d (see nv_trim_space()).
+ */
+
+char *nv_trim_char_strict(char *string, char trim) {
+ int count = 0;
+ char *trimmed;
+
+ trimmed = trim_char(string, trim, &count);
+
+ if (count == 0 || count == 2) {
+ return trimmed;
+ }
+
+ return NULL;
+}
diff --git a/common-utils/common-utils.h b/common-utils/common-utils.h
index 7e2838f..6dced25 100644
--- a/common-utils/common-utils.h
+++ b/common-utils/common-utils.h
@@ -70,6 +70,7 @@ char *nvasprintf(const char *fmt, ...) NV_ATTRIBUTE_PRINTF(1, 2);
void nvfree(void *s);
char *tilde_expansion(const char *str);
+char *nv_prepend_to_string_list(char *list, const char *item, const char *delim);
TextRows *nv_format_text_rows(const char *prefix,
const char *str,
@@ -89,6 +90,10 @@ void fmt(FILE *stream, const char *prefix, const char *fmt, ...) NV_ATTRIBUTE_PR
char *fget_next_line(FILE *fp, int *eof);
+char *nv_trim_space(char *string);
+char *nv_trim_char(char *string, char trim);
+char *nv_trim_char_strict(char *string, char trim);
+
/*
* NV_VSNPRINTF(): macro that assigns buf using vsnprintf(). This is
* correct for differing semantics of the vsnprintf() return value:
diff --git a/version.mk b/version.mk
index 69efa2d..8e97966 100644
--- a/version.mk
+++ b/version.mk
@@ -1 +1 @@
-NVIDIA_VERSION = 319.12
+NVIDIA_VERSION = 319.17