From 300900516d1e15edd86ea0512f9b5ccda85d150e Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 14 Feb 2017 09:03:27 +1100 Subject: mesa: remove tabs in dri xmlconfig.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Nicolai Hähnle --- src/mesa/drivers/dri/common/xmlconfig.c | 724 ++++++++++++++++---------------- 1 file changed, 362 insertions(+), 362 deletions(-) (limited to 'src/mesa/drivers/dri') diff --git a/src/mesa/drivers/dri/common/xmlconfig.c b/src/mesa/drivers/dri/common/xmlconfig.c index 4c1b34543c1..d4649370ee2 100644 --- a/src/mesa/drivers/dri/common/xmlconfig.c +++ b/src/mesa/drivers/dri/common/xmlconfig.c @@ -77,15 +77,15 @@ __getProgramName() static const char *progname; if (progname == NULL) { - const char *e = getexecname(); - if (e != NULL) { - /* Have to make a copy since getexecname can return a readonly - string, but basename expects to be able to modify its arg. */ - char *n = strdup(e); - if (n != NULL) { - progname = basename(n); - } - } + const char *e = getexecname(); + if (e != NULL) { + /* Have to make a copy since getexecname can return a readonly + string, but basename expects to be able to modify its arg. */ + char *n = strdup(e); + if (n != NULL) { + progname = basename(n); + } + } } return progname; } @@ -126,17 +126,17 @@ findOption(const driOptionCache *cache, const char *name) /* compute a hash from the variable length name */ for (i = 0, shift = 0; i < len; ++i, shift = (shift+8) & 31) - hash += (uint32_t)name[i] << shift; + hash += (uint32_t)name[i] << shift; hash *= hash; hash = (hash >> (16-cache->tableSize/2)) & mask; /* this is just the starting point of the linear search for the option */ for (i = 0; i < size; ++i, hash = (hash+1) & mask) { /* if we hit an empty entry then the option is not defined (yet) */ - if (cache->info[hash].name == 0) - break; - else if (!strcmp (name, cache->info[hash].name)) - break; + if (cache->info[hash].name == 0) + break; + else if (!strcmp (name, cache->info[hash].name)) + break; } /* this assertion fails if the hash table is full */ assert (i < size); @@ -148,8 +148,8 @@ findOption(const driOptionCache *cache, const char *name) #define XSTRDUP(dest,source) do { \ uint32_t len = strlen (source); \ if (!(dest = malloc(len+1))) { \ - fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \ - abort(); \ + fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \ + abort(); \ } \ memcpy (dest, source, len+1); \ } while (0) @@ -164,9 +164,9 @@ bsearchStr (const XML_Char *name, const XML_Char *elems[], uint32_t count) const XML_Char **found; found = bsearch (&name, elems, count, sizeof (XML_Char *), compare); if (found) - return found - elems; + return found - elems; else - return count; + return count; } /** \brief Locale-independent integer parser. @@ -190,39 +190,39 @@ strToI(const XML_Char *string, const XML_Char **tail, int base) assert (radix >= 2 && radix <= 36); if (*string == '-') { - sign = -1; - string++; + sign = -1; + string++; } else if (*string == '+') - string++; + string++; if (base == 0 && *string == '0') { - numberFound = true; - if (*(string+1) == 'x' || *(string+1) == 'X') { - radix = 16; - string += 2; - } else { - radix = 8; - string++; - } + numberFound = true; + if (*(string+1) == 'x' || *(string+1) == 'X') { + radix = 16; + string += 2; + } else { + radix = 8; + string++; + } } do { - int digit = -1; - if (radix <= 10) { - if (*string >= '0' && *string < '0' + radix) - digit = *string - '0'; - } else { - if (*string >= '0' && *string <= '9') - digit = *string - '0'; - else if (*string >= 'a' && *string < 'a' + radix - 10) - digit = *string - 'a' + 10; - else if (*string >= 'A' && *string < 'A' + radix - 10) - digit = *string - 'A' + 10; - } - if (digit != -1) { - numberFound = true; - result = radix*result + digit; - string++; - } else - break; + int digit = -1; + if (radix <= 10) { + if (*string >= '0' && *string < '0' + radix) + digit = *string - '0'; + } else { + if (*string >= '0' && *string <= '9') + digit = *string - '0'; + else if (*string >= 'a' && *string < 'a' + radix - 10) + digit = *string - 'a' + 10; + else if (*string >= 'A' && *string < 'A' + radix - 10) + digit = *string - 'A' + 10; + } + if (digit != -1) { + numberFound = true; + result = radix*result + digit; + string++; + } else + break; } while (true); *tail = numberFound ? string : start; return sign * result; @@ -249,41 +249,41 @@ strToF(const XML_Char *string, const XML_Char **tail) /* sign */ if (*string == '-') { - sign = -1.0f; - string++; + sign = -1.0f; + string++; } else if (*string == '+') - string++; + string++; /* first pass: determine position of decimal point, number of * digits, exponent and the end of the number. */ numStart = string; while (*string >= '0' && *string <= '9') { - string++; - nDigits++; + string++; + nDigits++; } pointPos = nDigits; if (*string == '.') { - string++; - while (*string >= '0' && *string <= '9') { - string++; - nDigits++; - } + string++; + while (*string >= '0' && *string <= '9') { + string++; + nDigits++; + } } if (nDigits == 0) { - /* no digits, no number */ - *tail = start; - return 0.0f; + /* no digits, no number */ + *tail = start; + return 0.0f; } *tail = string; if (*string == 'e' || *string == 'E') { - const XML_Char *expTail; - exponent = strToI (string+1, &expTail, 10); - if (expTail == string+1) - exponent = 0; - else - *tail = expTail; + const XML_Char *expTail; + exponent = strToI (string+1, &expTail, 10); + if (expTail == string+1) + exponent = 0; + else + *tail = expTail; } else - exponent = 0; + exponent = 0; string = numStart; /* scale of the first digit */ @@ -291,13 +291,13 @@ strToF(const XML_Char *string, const XML_Char **tail) /* second pass: parse digits */ do { - if (*string != '.') { - assert (*string >= '0' && *string <= '9'); - result += scale * (float)(*string - '0'); - scale *= 0.1f; - nDigits--; - } - string++; + if (*string != '.') { + assert (*string >= '0' && *string <= '9'); + result += scale * (float)(*string - '0'); + scale *= 0.1f; + nDigits--; + } + string++; } while (nDigits > 0); return result; @@ -312,36 +312,36 @@ parseValue(driOptionValue *v, driOptionType type, const XML_Char *string) string += strspn (string, " \f\n\r\t\v"); switch (type) { case DRI_BOOL: - if (!strcmp (string, "false")) { - v->_bool = false; - tail = string + 5; - } else if (!strcmp (string, "true")) { - v->_bool = true; - tail = string + 4; - } - else - return false; - break; + if (!strcmp (string, "false")) { + v->_bool = false; + tail = string + 5; + } else if (!strcmp (string, "true")) { + v->_bool = true; + tail = string + 4; + } + else + return false; + break; case DRI_ENUM: /* enum is just a special integer */ case DRI_INT: - v->_int = strToI (string, &tail, 0); - break; + v->_int = strToI (string, &tail, 0); + break; case DRI_FLOAT: - v->_float = strToF (string, &tail); - break; + v->_float = strToF (string, &tail); + break; case DRI_STRING: - free (v->_string); - v->_string = strndup(string, STRING_CONF_MAXLEN); - return GL_TRUE; + free (v->_string); + v->_string = strndup(string, STRING_CONF_MAXLEN); + return GL_TRUE; } if (tail == string) - return false; /* empty string (or containing only white-space) */ + return false; /* empty string (or containing only white-space) */ /* skip trailing white space */ if (*tail) - tail += strspn (tail, " \f\n\r\t\v"); + tail += strspn (tail, " \f\n\r\t\v"); if (*tail) - return false; /* something left over that is not part of value */ + return false; /* something left over that is not part of value */ return true; } @@ -358,50 +358,50 @@ parseRanges(driOptionInfo *info, const XML_Char *string) /* pass 1: determine the number of ranges (number of commas + 1) */ range = cp; for (nRanges = 1; *range; ++range) - if (*range == ',') - ++nRanges; + if (*range == ',') + ++nRanges; if ((ranges = malloc(nRanges*sizeof(driOptionRange))) == NULL) { - fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); - abort(); + fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); + abort(); } /* pass 2: parse all ranges into preallocated array */ range = cp; for (i = 0; i < nRanges; ++i) { - XML_Char *end, *sep; - assert (range); - end = strchr (range, ','); - if (end) - *end = '\0'; - sep = strchr (range, ':'); - if (sep) { /* non-empty interval */ - *sep = '\0'; - if (!parseValue (&ranges[i].start, info->type, range) || - !parseValue (&ranges[i].end, info->type, sep+1)) - break; - if (info->type == DRI_INT && - ranges[i].start._int > ranges[i].end._int) - break; - if (info->type == DRI_FLOAT && - ranges[i].start._float > ranges[i].end._float) - break; - } else { /* empty interval */ - if (!parseValue (&ranges[i].start, info->type, range)) - break; - ranges[i].end = ranges[i].start; - } - if (end) - range = end+1; - else - range = NULL; + XML_Char *end, *sep; + assert (range); + end = strchr (range, ','); + if (end) + *end = '\0'; + sep = strchr (range, ':'); + if (sep) { /* non-empty interval */ + *sep = '\0'; + if (!parseValue (&ranges[i].start, info->type, range) || + !parseValue (&ranges[i].end, info->type, sep+1)) + break; + if (info->type == DRI_INT && + ranges[i].start._int > ranges[i].end._int) + break; + if (info->type == DRI_FLOAT && + ranges[i].start._float > ranges[i].end._float) + break; + } else { /* empty interval */ + if (!parseValue (&ranges[i].start, info->type, range)) + break; + ranges[i].end = ranges[i].start; + } + if (end) + range = end+1; + else + range = NULL; } free(cp); if (i < nRanges) { - free(ranges); - return false; + free(ranges); + return false; } else - assert (range == NULL); + assert (range == NULL); info->nRanges = nRanges; info->ranges = ranges; @@ -415,25 +415,25 @@ checkValue(const driOptionValue *v, const driOptionInfo *info) uint32_t i; assert (info->type != DRI_BOOL); /* should be caught by the parser */ if (info->nRanges == 0) - return true; + return true; switch (info->type) { case DRI_ENUM: /* enum is just a special integer */ case DRI_INT: - for (i = 0; i < info->nRanges; ++i) - if (v->_int >= info->ranges[i].start._int && - v->_int <= info->ranges[i].end._int) - return true; - break; + for (i = 0; i < info->nRanges; ++i) + if (v->_int >= info->ranges[i].start._int && + v->_int <= info->ranges[i].end._int) + return true; + break; case DRI_FLOAT: - for (i = 0; i < info->nRanges; ++i) - if (v->_float >= info->ranges[i].start._float && - v->_float <= info->ranges[i].end._float) - return true; - break; + for (i = 0; i < info->nRanges; ++i) + if (v->_float >= info->ranges[i].start._float && + v->_float <= info->ranges[i].end._float) + return true; + break; case DRI_STRING: - break; + break; default: - assert (0); /* should never happen */ + assert (0); /* should never happen */ } return false; } @@ -490,15 +490,15 @@ __driUtilMessage(const char *f, ...) #define XML_FATAL1(msg) do { \ fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \ data->name, \ - (int) XML_GetCurrentLineNumber(data->parser), \ + (int) XML_GetCurrentLineNumber(data->parser), \ (int) XML_GetCurrentColumnNumber(data->parser)); \ abort();\ } while (0) #define XML_FATAL(msg,args...) do { \ fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \ data->name, \ - (int) XML_GetCurrentLineNumber(data->parser), \ - (int) XML_GetCurrentColumnNumber(data->parser), \ + (int) XML_GetCurrentLineNumber(data->parser), \ + (int) XML_GetCurrentColumnNumber(data->parser), \ args); \ abort();\ } while (0) @@ -537,16 +537,16 @@ parseEnumAttr(struct OptInfoData *data, const XML_Char **attr) driOptionValue v; uint32_t opt = data->curOption; for (i = 0; attr[i]; i += 2) { - if (!strcmp (attr[i], "value")) value = attr[i+1]; - else if (!strcmp (attr[i], "text")) text = attr[i+1]; - else XML_FATAL("illegal enum attribute: %s.", attr[i]); + if (!strcmp (attr[i], "value")) value = attr[i+1]; + else if (!strcmp (attr[i], "text")) text = attr[i+1]; + else XML_FATAL("illegal enum attribute: %s.", attr[i]); } if (!value) XML_FATAL1 ("value attribute missing in enum."); if (!text) XML_FATAL1 ("text attribute missing in enum."); if (!parseValue (&v, data->cache->info[opt].type, value)) - XML_FATAL ("illegal enum value: %s.", value); + XML_FATAL ("illegal enum value: %s.", value); if (!checkValue (&v, &data->cache->info[opt])) - XML_FATAL ("enum value out of valid range: %s.", value); + XML_FATAL ("enum value out of valid range: %s.", value); } /** \brief Parse attributes of a description element. @@ -560,9 +560,9 @@ parseDescAttr(struct OptInfoData *data, const XML_Char **attr) uint32_t i; const XML_Char *lang = NULL, *text = NULL; for (i = 0; attr[i]; i += 2) { - if (!strcmp (attr[i], "lang")) lang = attr[i+1]; - else if (!strcmp (attr[i], "text")) text = attr[i+1]; - else XML_FATAL("illegal description attribute: %s.", attr[i]); + if (!strcmp (attr[i], "lang")) lang = attr[i+1]; + else if (!strcmp (attr[i], "text")) text = attr[i+1]; + else XML_FATAL("illegal description attribute: %s.", attr[i]); } if (!lang) XML_FATAL1 ("lang attribute missing in description."); if (!text) XML_FATAL1 ("text attribute missing in description."); @@ -579,10 +579,10 @@ parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr) driOptionCache *cache = data->cache; uint32_t opt, i; for (i = 0; attr[i]; i += 2) { - uint32_t attrName = bsearchStr (attr[i], optAttr, OA_COUNT); - if (attrName >= OA_COUNT) - XML_FATAL ("illegal option attribute: %s", attr[i]); - attrVal[attrName] = attr[i+1]; + uint32_t attrName = bsearchStr (attr[i], optAttr, OA_COUNT); + if (attrName >= OA_COUNT) + XML_FATAL ("illegal option attribute: %s", attr[i]); + attrVal[attrName] = attr[i+1]; } if (!attrVal[OA_NAME]) XML_FATAL1 ("name attribute missing in option."); if (!attrVal[OA_TYPE]) XML_FATAL1 ("type attribute missing in option."); @@ -590,48 +590,48 @@ parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr) opt = findOption (cache, attrVal[OA_NAME]); if (cache->info[opt].name) - XML_FATAL ("option %s redefined.", attrVal[OA_NAME]); + XML_FATAL ("option %s redefined.", attrVal[OA_NAME]); data->curOption = opt; XSTRDUP (cache->info[opt].name, attrVal[OA_NAME]); if (!strcmp (attrVal[OA_TYPE], "bool")) - cache->info[opt].type = DRI_BOOL; + cache->info[opt].type = DRI_BOOL; else if (!strcmp (attrVal[OA_TYPE], "enum")) - cache->info[opt].type = DRI_ENUM; + cache->info[opt].type = DRI_ENUM; else if (!strcmp (attrVal[OA_TYPE], "int")) - cache->info[opt].type = DRI_INT; + cache->info[opt].type = DRI_INT; else if (!strcmp (attrVal[OA_TYPE], "float")) - cache->info[opt].type = DRI_FLOAT; + cache->info[opt].type = DRI_FLOAT; else if (!strcmp (attrVal[OA_TYPE], "string")) - cache->info[opt].type = DRI_STRING; + cache->info[opt].type = DRI_STRING; else - XML_FATAL ("illegal type in option: %s.", attrVal[OA_TYPE]); + XML_FATAL ("illegal type in option: %s.", attrVal[OA_TYPE]); defaultVal = getenv (cache->info[opt].name); if (defaultVal != NULL) { /* don't use XML_WARNING, we want the user to see this! */ - fprintf (stderr, - "ATTENTION: default value of option %s overridden by environment.\n", - cache->info[opt].name); + fprintf (stderr, + "ATTENTION: default value of option %s overridden by environment.\n", + cache->info[opt].name); } else - defaultVal = attrVal[OA_DEFAULT]; + defaultVal = attrVal[OA_DEFAULT]; if (!parseValue (&cache->values[opt], cache->info[opt].type, defaultVal)) - XML_FATAL ("illegal default value for %s: %s.", cache->info[opt].name, defaultVal); + XML_FATAL ("illegal default value for %s: %s.", cache->info[opt].name, defaultVal); if (attrVal[OA_VALID]) { - if (cache->info[opt].type == DRI_BOOL) - XML_FATAL1 ("boolean option with valid attribute."); - if (!parseRanges (&cache->info[opt], attrVal[OA_VALID])) - XML_FATAL ("illegal valid attribute: %s.", attrVal[OA_VALID]); - if (!checkValue (&cache->values[opt], &cache->info[opt])) - XML_FATAL ("default value out of valid range '%s': %s.", - attrVal[OA_VALID], defaultVal); + if (cache->info[opt].type == DRI_BOOL) + XML_FATAL1 ("boolean option with valid attribute."); + if (!parseRanges (&cache->info[opt], attrVal[OA_VALID])) + XML_FATAL ("illegal valid attribute: %s.", attrVal[OA_VALID]); + if (!checkValue (&cache->values[opt], &cache->info[opt])) + XML_FATAL ("default value out of valid range '%s': %s.", + attrVal[OA_VALID], defaultVal); } else if (cache->info[opt].type == DRI_ENUM) { - XML_FATAL1 ("valid attribute missing in option (mandatory for enums)."); + XML_FATAL1 ("valid attribute missing in option (mandatory for enums)."); } else { - cache->info[opt].nRanges = 0; - cache->info[opt].ranges = NULL; + cache->info[opt].nRanges = 0; + cache->info[opt].ranges = NULL; } } @@ -643,49 +643,49 @@ optInfoStartElem(void *userData, const XML_Char *name, const XML_Char **attr) enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT); switch (elem) { case OI_DRIINFO: - if (data->inDriInfo) - XML_FATAL1 ("nested elements."); - if (attr[0]) - XML_FATAL1 ("attributes specified on element."); - data->inDriInfo = true; - break; + if (data->inDriInfo) + XML_FATAL1 ("nested elements."); + if (attr[0]) + XML_FATAL1 ("attributes specified on element."); + data->inDriInfo = true; + break; case OI_SECTION: - if (!data->inDriInfo) - XML_FATAL1 ("
must be inside ."); - if (data->inSection) - XML_FATAL1 ("nested
elements."); - if (attr[0]) - XML_FATAL1 ("attributes specified on
element."); - data->inSection = true; - break; + if (!data->inDriInfo) + XML_FATAL1 ("
must be inside ."); + if (data->inSection) + XML_FATAL1 ("nested
elements."); + if (attr[0]) + XML_FATAL1 ("attributes specified on
element."); + data->inSection = true; + break; case OI_DESCRIPTION: - if (!data->inSection && !data->inOption) - XML_FATAL1 (" must be inside or inDesc) - XML_FATAL1 ("nested elements."); - data->inDesc = true; - parseDescAttr (data, attr); - break; + if (!data->inSection && !data->inOption) + XML_FATAL1 (" must be inside or inDesc) + XML_FATAL1 ("nested elements."); + data->inDesc = true; + parseDescAttr (data, attr); + break; case OI_OPTION: - if (!data->inSection) - XML_FATAL1 ("