]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - util.c
factoring out the closing-paren handling code since it'll be used recursively
[xonotic/gmqcc.git] / util.c
diff --git a/util.c b/util.c
index 9a23aed96400f62270240cc7d3d3d5421858e9da..3275ad82520367f00a2106af828baefb6b2d78fd 100644 (file)
--- a/util.c
+++ b/util.c
@@ -137,39 +137,6 @@ char *util_strchp(const char *s, const char *e) {
     return util_strdup(s);
 }
 
-/*
- * Remove newline from a string (if it exists).  This is
- * done pointer wise instead of strlen(), and an array
- * access.
- */
-char *util_strrnl(const char *src) {
-    char   *cpy = NULL;
-
-    if (src) {
-        cpy = (char*)src;
-        while (*cpy && *cpy != '\n')
-            cpy++;
-
-        *cpy = '\0';
-    }
-    return (char*)src;
-}
-
-/*
- * Removes any whitespace prefixed on a string by moving
- * skipping past it, and stroing the skip distance, so
- * the string can later be freed (if it was allocated)
- */
-char *util_strsws(const char *skip) {
-    size_t size = 0;
-    if (!skip)
-        return NULL;
-
-    while (*skip == ' ' || *skip == '\t')
-        skip++,size++;
-    return util_strdup(skip-size);
-}
-
 /*
  * Returns true if string is all uppercase, otherwise
  * it returns false.
@@ -196,6 +163,10 @@ bool util_strdigit(const char *str) {
     return true;
 }
 
+bool util_strncmpexact(const char *src, const char *ned, size_t len) {
+    return (!strncmp(src, ned, len) && !src[len]);
+}
+
 void util_debug(const char *area, const char *ms, ...) {
     va_list  va;
     if (!opts_debug)
@@ -399,3 +370,11 @@ int util_getline(char **lineptr, size_t *n, FILE *stream) {
     *pos = '\0';
     return (ret = pos - *lineptr);
 }
+
+/* TODO: opts.c? when it gets large enugh */
+/* global options */
+bool opts_debug                     = false;
+bool opts_memchk                    = false;
+bool opts_darkplaces_stringtablebug = false;
+bool opts_omit_nullcode             = false;
+int  opts_compiler                  = COMPILER_GMQCC;