| File: | util/fontxlfd.c |
| Location: | line 446, column 2 |
| Description: | Value stored to 'ptr2' is never read |
| 1 | /* |
| 2 | |
| 3 | Copyright 1990, 1998 The Open Group |
| 4 | |
| 5 | Permission to use, copy, modify, distribute, and sell this software and its |
| 6 | documentation for any purpose is hereby granted without fee, provided that |
| 7 | the above copyright notice appear in all copies and that both that |
| 8 | copyright notice and this permission notice appear in supporting |
| 9 | documentation. |
| 10 | |
| 11 | The above copyright notice and this permission notice shall be included |
| 12 | in all copies or substantial portions of the Software. |
| 13 | |
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 17 | IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | OTHER DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | Except as contained in this notice, the name of The Open Group shall |
| 23 | not be used in advertising or otherwise to promote the sale, use or |
| 24 | other dealings in this Software without prior written authorization |
| 25 | from The Open Group. |
| 26 | |
| 27 | */ |
| 28 | |
| 29 | /* |
| 30 | * Author: Keith Packard, MIT X Consortium |
| 31 | */ |
| 32 | |
| 33 | #ifdef HAVE_CONFIG_H1 |
| 34 | #include <config.h> |
| 35 | #endif |
| 36 | #include "libxfontint.h" |
| 37 | #include <X11/fonts/fontmisc.h> |
| 38 | #include <X11/fonts/fontstruct.h> |
| 39 | #include <X11/fonts/fontxlfd.h> |
| 40 | #include <X11/fonts/fontutil.h> |
| 41 | #include <X11/Xos.h> |
| 42 | #include <math.h> |
| 43 | #include <stdlib.h> |
| 44 | #if defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV) |
| 45 | #define NO_LOCALE |
| 46 | #endif |
| 47 | #ifndef NO_LOCALE |
| 48 | #include <locale.h> |
| 49 | #endif |
| 50 | #include <ctype.h> |
| 51 | #include <stdio.h> /* for sprintf() */ |
| 52 | |
| 53 | static char * |
| 54 | GetInt(char *ptr, int *val) |
| 55 | { |
| 56 | if (*ptr == '*') { |
| 57 | *val = -1; |
| 58 | ptr++; |
| 59 | } else |
| 60 | for (*val = 0; *ptr >= '0' && *ptr <= '9';) |
| 61 | *val = *val * 10 + *ptr++ - '0'; |
| 62 | if (*ptr == '-') |
| 63 | return ptr; |
| 64 | return (char *) 0; |
| 65 | } |
| 66 | |
| 67 | #define minchar(p)((p).min_char_low + ((p).min_char_high << 8)) ((p).min_char_low + ((p).min_char_high << 8)) |
| 68 | #define maxchar(p)((p).max_char_low + ((p).max_char_high << 8)) ((p).max_char_low + ((p).max_char_high << 8)) |
| 69 | |
| 70 | |
| 71 | #ifndef NO_LOCALE |
| 72 | static struct lconv *locale = 0; |
| 73 | #endif |
| 74 | static const char *radix = ".", *plus = "+", *minus = "-"; |
| 75 | |
| 76 | static char * |
| 77 | readreal(char *ptr, double *result) |
| 78 | { |
| 79 | char buffer[80], *p1, *p2; |
| 80 | |
| 81 | #ifndef NO_LOCALE |
| 82 | /* Figure out what symbols apply in this locale */ |
| 83 | |
| 84 | if (!locale) |
| 85 | { |
| 86 | locale = localeconv(); |
| 87 | if (locale->decimal_point && *locale->decimal_point) |
| 88 | radix = locale->decimal_point; |
| 89 | if (locale->positive_sign && *locale->positive_sign) |
| 90 | plus = locale->positive_sign; |
| 91 | if (locale->negative_sign && *locale->negative_sign) |
| 92 | minus = locale->negative_sign; |
| 93 | } |
| 94 | #endif |
| 95 | /* Copy the first 80 chars of ptr into our local buffer, changing |
| 96 | symbols as needed. */ |
| 97 | for (p1 = ptr, p2 = buffer; |
| 98 | *p1 && (p2 - buffer) < sizeof(buffer) - 1; |
| 99 | p1++, p2++) |
| 100 | { |
| 101 | switch(*p1) |
| 102 | { |
| 103 | case '~': *p2 = *minus; break; |
| 104 | case '+': *p2 = *plus; break; |
| 105 | case '.': *p2 = *radix; break; |
| 106 | default: *p2 = *p1; |
| 107 | } |
| 108 | } |
| 109 | *p2 = 0; |
| 110 | |
| 111 | /* Now we have something that strtod() can interpret... do it. */ |
| 112 | *result = strtod(buffer, &p1); |
| 113 | /* Return NULL if failure, pointer past number if success */ |
| 114 | return (p1 == buffer) ? (char *)0 : (ptr + (p1 - buffer)); |
| 115 | } |
| 116 | |
| 117 | static char * |
| 118 | xlfd_double_to_text(double value, char *buffer, int space_required) |
| 119 | { |
| 120 | register char *p1; |
| 121 | int ndigits, exponent; |
| 122 | |
| 123 | #ifndef NO_LOCALE |
| 124 | if (!locale) |
| 125 | { |
| 126 | locale = localeconv(); |
| 127 | if (locale->decimal_point && *locale->decimal_point) |
| 128 | radix = locale->decimal_point; |
| 129 | if (locale->positive_sign && *locale->positive_sign) |
| 130 | plus = locale->positive_sign; |
| 131 | if (locale->negative_sign && *locale->negative_sign) |
| 132 | minus = locale->negative_sign; |
| 133 | } |
| 134 | #endif |
| 135 | |
| 136 | if (space_required) |
| 137 | *buffer++ = ' '; |
| 138 | |
| 139 | /* Render the number using printf's idea of formatting */ |
| 140 | sprintf(buffer, "%.*le", XLFD_NDIGITS, value)__builtin___sprintf_chk (buffer, 0, __builtin_object_size (buffer , 2 > 1 ? 1 : 0), "%.*le", 3, value); |
| 141 | |
| 142 | /* Find and read the exponent value */ |
| 143 | for (p1 = buffer + strlen(buffer); |
| 144 | *p1-- != 'e' && p1[1] != 'E';); |
| 145 | exponent = atoi(p1 + 2); |
| 146 | if (value == 0.0) exponent = 0; |
| 147 | |
| 148 | /* Figure out how many digits are significant */ |
| 149 | while (p1 >= buffer && (!isdigit((unsigned char)*p1) || *p1 == '0')) p1--; |
| 150 | ndigits = 0; |
| 151 | while (p1 >= buffer) if (isdigit((unsigned char)*p1--)) ndigits++; |
| 152 | |
| 153 | /* Figure out notation to use */ |
| 154 | if (exponent >= XLFD_NDIGITS3 || ndigits - exponent > XLFD_NDIGITS3 + 1) |
| 155 | { |
| 156 | /* Scientific */ |
| 157 | sprintf(buffer, "%.*le", ndigits - 1, value)__builtin___sprintf_chk (buffer, 0, __builtin_object_size (buffer , 2 > 1 ? 1 : 0), "%.*le", ndigits - 1, value); |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | /* Fixed */ |
| 162 | ndigits -= exponent + 1; |
| 163 | if (ndigits < 0) ndigits = 0; |
| 164 | sprintf(buffer, "%.*lf", ndigits, value)__builtin___sprintf_chk (buffer, 0, __builtin_object_size (buffer , 2 > 1 ? 1 : 0), "%.*lf", ndigits, value); |
| 165 | if (exponent < 0) |
| 166 | { |
| 167 | p1 = buffer; |
| 168 | while (*p1 && *p1 != '0') p1++; |
| 169 | while (*p1++) p1[-1] = *p1; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /* Last step, convert the locale-specific sign and radix characters |
| 174 | to our own. */ |
| 175 | for (p1 = buffer; *p1; p1++) |
| 176 | { |
| 177 | if (*p1 == *minus) *p1 = '~'; |
| 178 | else if (*p1 == *plus) *p1 = '+'; |
| 179 | else if (*p1 == *radix) *p1 = '.'; |
| 180 | } |
| 181 | |
| 182 | return buffer - space_required; |
| 183 | } |
| 184 | |
| 185 | double |
| 186 | xlfd_round_double(double x) |
| 187 | { |
| 188 | /* Utility for XLFD users to round numbers to XLFD_NDIGITS |
| 189 | significant digits. How do you round to n significant digits on |
| 190 | a binary machine? */ |
| 191 | |
| 192 | #if defined(i386) || defined(__i386__) || \ |
| 193 | defined(ia64) || defined(__ia64__) || \ |
| 194 | defined(__alpha__) || defined(__alpha) || \ |
| 195 | defined(__hppa__) || \ |
| 196 | defined(__amd64__1) || defined(__amd641) || \ |
| 197 | defined(sgi) |
| 198 | #include <float.h> |
| 199 | |
| 200 | /* if we have IEEE 754 fp, we can round to binary digits... */ |
| 201 | |
| 202 | #if (FLT_RADIX2 == 2) && (DBL_DIG15 == 15) && (DBL_MANT_DIG53 == 53) |
| 203 | |
| 204 | #ifndef M_LN20.693147180559945309417232121458176568 |
| 205 | #define M_LN20.693147180559945309417232121458176568 0.69314718055994530942 |
| 206 | #endif |
| 207 | #ifndef M_LN102.30258509299404568401799145468436421 |
| 208 | #define M_LN102.30258509299404568401799145468436421 2.30258509299404568402 |
| 209 | #endif |
| 210 | |
| 211 | /* convert # of decimal digits to # of binary digits */ |
| 212 | #define XLFD_NDIGITS_2((int)(3 * 2.30258509299404568401799145468436421 / 0.693147180559945309417232121458176568 + 0.5)) ((int)(XLFD_NDIGITS3 * M_LN102.30258509299404568401799145468436421 / M_LN20.693147180559945309417232121458176568 + 0.5)) |
| 213 | |
| 214 | union conv_d { |
| 215 | double d; |
| 216 | unsigned char b[8]; |
| 217 | } d; |
| 218 | int i,j,k,d_exp; |
| 219 | |
| 220 | if (x == 0) |
| 221 | return x; |
| 222 | |
| 223 | /* do minor sanity check for IEEE 754 fp and correct byte order */ |
| 224 | d.d = 1.0; |
| 225 | if (sizeof(double) == 8 && d.b[7] == 0x3f && d.b[6] == 0xf0) { |
| 226 | |
| 227 | /* |
| 228 | * this code will round IEEE 754 double to XLFD_NDIGITS_2 binary digits |
| 229 | */ |
| 230 | |
| 231 | d.d = x; |
| 232 | d_exp = (d.b[7] << 4) | (d.b[6] >> 4); |
| 233 | |
| 234 | i = (DBL_MANT_DIG53-XLFD_NDIGITS_2((int)(3 * 2.30258509299404568401799145468436421 / 0.693147180559945309417232121458176568 + 0.5))) >> 3; |
| 235 | j = 1 << ((DBL_MANT_DIG53-XLFD_NDIGITS_2((int)(3 * 2.30258509299404568401799145468436421 / 0.693147180559945309417232121458176568 + 0.5))) & 0x07); |
| 236 | for (; i<7; i++) { |
| 237 | k = d.b[i] + j; |
| 238 | d.b[i] = k; |
| 239 | if (k & 0x100) j = 1; |
| 240 | else break; |
| 241 | } |
| 242 | if ((i==7) && ((d.b[6] & 0xf0) != ((d_exp<<4) & 0xf0))) { |
| 243 | /* mantissa overflow: increment exponent */ |
| 244 | d_exp = (d_exp & 0x800 ) | ((d_exp & 0x7ff) + 1); |
| 245 | d.b[7] = d_exp >> 4; |
| 246 | d.b[6] = (d.b[6] & 0x0f) | (d_exp << 4); |
| 247 | } |
| 248 | |
| 249 | i = (DBL_MANT_DIG53-XLFD_NDIGITS_2((int)(3 * 2.30258509299404568401799145468436421 / 0.693147180559945309417232121458176568 + 0.5))) >> 3; |
| 250 | j = 1 << ((DBL_MANT_DIG53-XLFD_NDIGITS_2((int)(3 * 2.30258509299404568401799145468436421 / 0.693147180559945309417232121458176568 + 0.5))) & 0x07); |
| 251 | d.b[i] &= ~(j-1); |
| 252 | for (;--i>=0;) d.b[i] = 0; |
| 253 | |
| 254 | return d.d; |
| 255 | } |
| 256 | else |
| 257 | #endif |
| 258 | #endif /* i386 || __i386__ */ |
| 259 | { |
| 260 | /* |
| 261 | * If not IEEE 754: Let printf() do it for you. |
| 262 | */ |
| 263 | |
| 264 | char buffer[40]; |
| 265 | |
| 266 | sprintf(buffer, "%.*lg", XLFD_NDIGITS, x)__builtin___sprintf_chk (buffer, 0, __builtin_object_size (buffer , 2 > 1 ? 1 : 0), "%.*lg", 3, x); |
| 267 | return atof(buffer); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | static char * |
| 272 | GetMatrix(char *ptr, FontScalablePtr vals, int which) |
| 273 | { |
| 274 | double *matrix; |
| 275 | |
| 276 | if (which == PIXELSIZE_MASK0x3) |
| 277 | matrix = vals->pixel_matrix; |
| 278 | else if (which == POINTSIZE_MASK0xc) |
| 279 | matrix = vals->point_matrix; |
| 280 | else return (char *)0; |
| 281 | |
| 282 | while (isspace((unsigned char)*ptr)) ptr++; |
| 283 | if (*ptr == '[') |
| 284 | { |
| 285 | /* This is a matrix containing real numbers. It would be nice |
| 286 | to use strtod() or sscanf() to read the numbers, but those |
| 287 | don't handle '~' for minus and we cannot force them to use a |
| 288 | "." for the radix. We'll have to do the hard work ourselves |
| 289 | (in readreal()). */ |
| 290 | |
| 291 | if ((ptr = readreal(++ptr, matrix + 0)) && |
| 292 | (ptr = readreal(ptr, matrix + 1)) && |
| 293 | (ptr = readreal(ptr, matrix + 2)) && |
| 294 | (ptr = readreal(ptr, matrix + 3))) |
| 295 | { |
| 296 | while (isspace((unsigned char)*ptr)) ptr++; |
| 297 | if (*ptr != ']') |
| 298 | ptr = (char *)0; |
| 299 | else |
| 300 | { |
| 301 | ptr++; |
| 302 | while (isspace((unsigned char)*ptr)) ptr++; |
| 303 | if (*ptr == '-') |
| 304 | { |
| 305 | if (which == POINTSIZE_MASK0xc) |
| 306 | vals->values_supplied |= POINTSIZE_ARRAY0x8; |
| 307 | else |
| 308 | vals->values_supplied |= PIXELSIZE_ARRAY0x2; |
| 309 | } |
| 310 | else ptr = (char *)0; |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | int value; |
| 317 | if ((ptr = GetInt(ptr, &value))) |
| 318 | { |
| 319 | vals->values_supplied &= ~which; |
| 320 | if (value > 0) |
| 321 | { |
| 322 | matrix[3] = (double)value; |
| 323 | if (which == POINTSIZE_MASK0xc) |
| 324 | { |
| 325 | matrix[3] /= 10.0; |
| 326 | vals->values_supplied |= POINTSIZE_SCALAR0x4; |
| 327 | } |
| 328 | else |
| 329 | vals->values_supplied |= PIXELSIZE_SCALAR0x1; |
| 330 | /* If we're concocting the pixelsize array from a scalar, |
| 331 | we will need to normalize element 0 for the pixel shape. |
| 332 | This is done in FontFileCompleteXLFD(). */ |
| 333 | matrix[0] = matrix[3]; |
| 334 | matrix[1] = matrix[2] = 0.0; |
| 335 | } |
| 336 | else if (value < 0) |
| 337 | { |
| 338 | if (which == POINTSIZE_MASK0xc) |
| 339 | vals->values_supplied |= POINTSIZE_WILDCARD0x20; |
| 340 | else |
| 341 | vals->values_supplied |= PIXELSIZE_WILDCARD0x10; |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | return ptr; |
| 346 | } |
| 347 | |
| 348 | |
| 349 | static void |
| 350 | append_ranges(char *fname, int nranges, fsRange *ranges) |
| 351 | { |
| 352 | if (nranges) |
| 353 | { |
| 354 | int i; |
| 355 | |
| 356 | strcat(fname, "[")__builtin___strcat_chk (fname, "[", __builtin_object_size (fname , 2 > 1 ? 1 : 0)); |
| 357 | for (i = 0; i < nranges && strlen(fname) < 1010; i++) |
| 358 | { |
| 359 | if (i) strcat(fname, " ")__builtin___strcat_chk (fname, " ", __builtin_object_size (fname , 2 > 1 ? 1 : 0)); |
| 360 | sprintf(fname + strlen(fname), "%d",__builtin___sprintf_chk (fname + strlen(fname), 0, __builtin_object_size (fname + strlen(fname), 2 > 1 ? 1 : 0), "%d", ((ranges[i] ).min_char_low + ((ranges[i]).min_char_high << 8))) |
| 361 | minchar(ranges[i]))__builtin___sprintf_chk (fname + strlen(fname), 0, __builtin_object_size (fname + strlen(fname), 2 > 1 ? 1 : 0), "%d", ((ranges[i] ).min_char_low + ((ranges[i]).min_char_high << 8))); |
| 362 | if (ranges[i].min_char_low == |
| 363 | ranges[i].max_char_low && |
| 364 | ranges[i].min_char_high == |
| 365 | ranges[i].max_char_high) continue; |
| 366 | sprintf(fname + strlen(fname), "_%d",__builtin___sprintf_chk (fname + strlen(fname), 0, __builtin_object_size (fname + strlen(fname), 2 > 1 ? 1 : 0), "_%d", ((ranges[i ]).max_char_low + ((ranges[i]).max_char_high << 8))) |
| 367 | maxchar(ranges[i]))__builtin___sprintf_chk (fname + strlen(fname), 0, __builtin_object_size (fname + strlen(fname), 2 > 1 ? 1 : 0), "_%d", ((ranges[i ]).max_char_low + ((ranges[i]).max_char_high << 8))); |
| 368 | } |
| 369 | strcat(fname, "]")__builtin___strcat_chk (fname, "]", __builtin_object_size (fname , 2 > 1 ? 1 : 0)); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | Bool |
| 374 | FontParseXLFDName(char *fname, FontScalablePtr vals, int subst) |
| 375 | { |
| 376 | register char *ptr; |
| 377 | register char *ptr1, |
| 378 | *ptr2, |
| 379 | *ptr3, |
| 380 | *ptr4; |
| 381 | register char *ptr5; |
| 382 | FontScalableRec tmpvals; |
| 383 | char replaceChar = '0'; |
| 384 | char tmpBuf[1024]; |
| 385 | int spacingLen; |
| 386 | int l; |
| 387 | char *p; |
| 388 | |
| 389 | bzero(&tmpvals, sizeof(tmpvals))__builtin___memset_chk (&tmpvals, 0, sizeof(tmpvals), __builtin_object_size (&tmpvals, 0)); |
| 390 | if (subst != FONT_XLFD_REPLACE_VALUE3) |
| 391 | *vals = tmpvals; |
| 392 | |
| 393 | if (!(*(ptr = fname) == '-' || (*ptr++ == '*' && *ptr == '-')) || /* fndry */ |
| 394 | !(ptr = strchr(ptr + 1, '-')) || /* family_name */ |
| 395 | !(ptr1 = ptr = strchr(ptr + 1, '-')) || /* weight_name */ |
| 396 | !(ptr = strchr(ptr + 1, '-')) || /* slant */ |
| 397 | !(ptr = strchr(ptr + 1, '-')) || /* setwidth_name */ |
| 398 | !(ptr = strchr(ptr + 1, '-')) || /* add_style_name */ |
| 399 | !(ptr = strchr(ptr + 1, '-')) || /* pixel_size */ |
| 400 | !(ptr = GetMatrix(ptr + 1, &tmpvals, PIXELSIZE_MASK0x3)) || |
| 401 | !(ptr2 = ptr = GetMatrix(ptr + 1, &tmpvals, POINTSIZE_MASK0xc)) || |
| 402 | !(ptr = GetInt(ptr + 1, &tmpvals.x)) || /* resolution_x */ |
| 403 | !(ptr3 = ptr = GetInt(ptr + 1, &tmpvals.y)) || /* resolution_y */ |
| 404 | !(ptr4 = ptr = strchr(ptr + 1, '-')) || /* spacing */ |
| 405 | !(ptr5 = ptr = GetInt(ptr + 1, &tmpvals.width)) || /* average_width */ |
| 406 | !(ptr = strchr(ptr + 1, '-')) || /* charset_registry */ |
| 407 | strchr(ptr + 1, '-'))/* charset_encoding */ |
| 408 | return FALSE0; |
| 409 | |
| 410 | /* Lop off HP charset subsetting enhancement. Interpreting this |
| 411 | field requires allocating some space in which to return the |
| 412 | results. So, to prevent memory leaks, this procedure will simply |
| 413 | lop off and ignore charset subsetting, and initialize the |
| 414 | relevant vals fields to zero. It's up to the caller to make its |
| 415 | own call to FontParseRanges() if it's interested in the charset |
| 416 | subsetting. */ |
| 417 | |
| 418 | if (subst != FONT_XLFD_REPLACE_NONE0 && |
| 419 | (p = strchr(strrchr(fname, '-'), '['))) |
| 420 | { |
| 421 | tmpvals.values_supplied |= CHARSUBSET_SPECIFIED0x40; |
| 422 | *p = '\0'; |
| 423 | } |
| 424 | |
| 425 | /* Fill in deprecated fields for the benefit of rasterizers that care |
| 426 | about them. */ |
| 427 | tmpvals.pixel = (tmpvals.pixel_matrix[3] >= 0) ? |
| 428 | (int)(tmpvals.pixel_matrix[3] + .5) : |
| 429 | (int)(tmpvals.pixel_matrix[3] - .5); |
| 430 | tmpvals.point = (tmpvals.point_matrix[3] >= 0) ? |
| 431 | (int)(tmpvals.point_matrix[3] * 10 + .5) : |
| 432 | (int)(tmpvals.point_matrix[3] * 10 - .5); |
| 433 | |
| 434 | spacingLen = ptr4 - ptr3 + 1; |
| 435 | |
| 436 | switch (subst) { |
| 437 | case FONT_XLFD_REPLACE_NONE0: |
| 438 | *vals = tmpvals; |
| 439 | break; |
| 440 | case FONT_XLFD_REPLACE_STAR1: |
| 441 | replaceChar = '*'; |
| 442 | case FONT_XLFD_REPLACE_ZERO2: |
| 443 | strcpy(tmpBuf, ptr2)__builtin___strcpy_chk (tmpBuf, ptr2, __builtin_object_size ( tmpBuf, 2 > 1 ? 1 : 0)); |
| 444 | ptr5 = tmpBuf + (ptr5 - ptr2); |
| 445 | ptr3 = tmpBuf + (ptr3 - ptr2); |
| 446 | ptr2 = tmpBuf; |
Value stored to 'ptr2' is never read | |
| 447 | ptr = ptr1 + 1; |
| 448 | |
| 449 | ptr = strchr(ptr, '-') + 1; /* skip weight */ |
| 450 | ptr = strchr(ptr, '-') + 1; /* skip slant */ |
| 451 | ptr = strchr(ptr, '-') + 1; /* skip setwidth_name */ |
| 452 | ptr = strchr(ptr, '-') + 1; /* skip add_style_name */ |
| 453 | |
| 454 | if ((ptr - fname) + spacingLen + strlen(ptr5) + 10 >= (unsigned)1024) |
| 455 | return FALSE0; |
| 456 | *ptr++ = replaceChar; |
| 457 | *ptr++ = '-'; |
| 458 | *ptr++ = replaceChar; |
| 459 | *ptr++ = '-'; |
| 460 | *ptr++ = '*'; |
| 461 | *ptr++ = '-'; |
| 462 | *ptr++ = '*'; |
| 463 | if (spacingLen > 2) |
| 464 | { |
| 465 | memmove(ptr, ptr3, spacingLen)__builtin___memmove_chk (ptr, ptr3, spacingLen, __builtin_object_size (ptr, 0)); |
| 466 | ptr += spacingLen; |
| 467 | } |
| 468 | else |
| 469 | { |
| 470 | *ptr++ = '-'; |
| 471 | *ptr++ = '*'; |
| 472 | *ptr++ = '-'; |
| 473 | } |
| 474 | *ptr++ = replaceChar; |
| 475 | strcpy(ptr, ptr5)__builtin___strcpy_chk (ptr, ptr5, __builtin_object_size (ptr , 2 > 1 ? 1 : 0)); |
| 476 | *vals = tmpvals; |
| 477 | break; |
| 478 | case FONT_XLFD_REPLACE_VALUE3: |
| 479 | if (vals->values_supplied & PIXELSIZE_MASK0x3) |
| 480 | { |
| 481 | tmpvals.values_supplied = |
| 482 | (tmpvals.values_supplied & ~PIXELSIZE_MASK0x3) | |
| 483 | (vals->values_supplied & PIXELSIZE_MASK0x3); |
| 484 | tmpvals.pixel_matrix[0] = vals->pixel_matrix[0]; |
| 485 | tmpvals.pixel_matrix[1] = vals->pixel_matrix[1]; |
| 486 | tmpvals.pixel_matrix[2] = vals->pixel_matrix[2]; |
| 487 | tmpvals.pixel_matrix[3] = vals->pixel_matrix[3]; |
| 488 | } |
| 489 | if (vals->values_supplied & POINTSIZE_MASK0xc) |
| 490 | { |
| 491 | tmpvals.values_supplied = |
| 492 | (tmpvals.values_supplied & ~POINTSIZE_MASK0xc) | |
| 493 | (vals->values_supplied & POINTSIZE_MASK0xc); |
| 494 | tmpvals.point_matrix[0] = vals->point_matrix[0]; |
| 495 | tmpvals.point_matrix[1] = vals->point_matrix[1]; |
| 496 | tmpvals.point_matrix[2] = vals->point_matrix[2]; |
| 497 | tmpvals.point_matrix[3] = vals->point_matrix[3]; |
| 498 | } |
| 499 | if (vals->x >= 0) |
| 500 | tmpvals.x = vals->x; |
| 501 | if (vals->y >= 0) |
| 502 | tmpvals.y = vals->y; |
| 503 | if (vals->width >= 0) |
| 504 | tmpvals.width = vals->width; |
| 505 | else if (vals->width < -1) /* overload: -1 means wildcard */ |
| 506 | tmpvals.width = -vals->width; |
| 507 | |
| 508 | |
| 509 | p = ptr1 + 1; /* weight field */ |
| 510 | l = strchr(p, '-') - p; |
| 511 | sprintf(tmpBuf, "%*.*s", l, l, p)__builtin___sprintf_chk (tmpBuf, 0, __builtin_object_size (tmpBuf , 2 > 1 ? 1 : 0), "%*.*s", l, l, p); |
| 512 | |
| 513 | p += l + 1; /* slant field */ |
| 514 | l = strchr(p, '-') - p; |
| 515 | sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p)__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "-%*.*s", l, l, p); |
| 516 | |
| 517 | p += l + 1; /* setwidth_name */ |
| 518 | l = strchr(p, '-') - p; |
| 519 | sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p)__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "-%*.*s", l, l, p); |
| 520 | |
| 521 | p += l + 1; /* add_style_name field */ |
| 522 | l = strchr(p, '-') - p; |
| 523 | sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p)__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "-%*.*s", l, l, p); |
| 524 | |
| 525 | strcat(tmpBuf, "-")__builtin___strcat_chk (tmpBuf, "-", __builtin_object_size (tmpBuf , 2 > 1 ? 1 : 0)); |
| 526 | if ((tmpvals.values_supplied & PIXELSIZE_MASK0x3) == PIXELSIZE_ARRAY0x2) |
| 527 | { |
| 528 | char buffer[80]; |
| 529 | strcat(tmpBuf, "[")__builtin___strcat_chk (tmpBuf, "[", __builtin_object_size (tmpBuf , 2 > 1 ? 1 : 0)); |
| 530 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[0],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [0], buffer, 0), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 531 | buffer, 0))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [0], buffer, 0), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 532 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[1],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [1], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 533 | buffer, 1))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [1], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 534 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[2],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [2], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 535 | buffer, 1))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [2], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 536 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[3],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [3], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 537 | buffer, 1))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix [3], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 538 | strcat(tmpBuf, "]")__builtin___strcat_chk (tmpBuf, "]", __builtin_object_size (tmpBuf , 2 > 1 ? 1 : 0)); |
| 539 | } |
| 540 | else |
| 541 | { |
| 542 | sprintf(tmpBuf + strlen(tmpBuf), "%d",__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "%d", (int)(tmpvals .pixel_matrix[3] + .5)) |
| 543 | (int)(tmpvals.pixel_matrix[3] + .5))__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "%d", (int)(tmpvals .pixel_matrix[3] + .5)); |
| 544 | } |
| 545 | strcat(tmpBuf, "-")__builtin___strcat_chk (tmpBuf, "-", __builtin_object_size (tmpBuf , 2 > 1 ? 1 : 0)); |
| 546 | if ((tmpvals.values_supplied & POINTSIZE_MASK0xc) == POINTSIZE_ARRAY0x8) |
| 547 | { |
| 548 | char buffer[80]; |
| 549 | strcat(tmpBuf, "[")__builtin___strcat_chk (tmpBuf, "[", __builtin_object_size (tmpBuf , 2 > 1 ? 1 : 0)); |
| 550 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[0],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [0], buffer, 0), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 551 | buffer, 0))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [0], buffer, 0), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 552 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[1],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [1], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 553 | buffer, 1))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [1], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 554 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[2],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [2], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 555 | buffer, 1))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [2], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 556 | strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[3],__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [3], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)) |
| 557 | buffer, 1))__builtin___strcat_chk (tmpBuf, xlfd_double_to_text(tmpvals.point_matrix [3], buffer, 1), __builtin_object_size (tmpBuf, 2 > 1 ? 1 : 0)); |
| 558 | strcat(tmpBuf, "]")__builtin___strcat_chk (tmpBuf, "]", __builtin_object_size (tmpBuf , 2 > 1 ? 1 : 0)); |
| 559 | } |
| 560 | else |
| 561 | { |
| 562 | sprintf(tmpBuf + strlen(tmpBuf), "%d",__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "%d", (int)(tmpvals .point_matrix[3] * 10.0 + .5)) |
| 563 | (int)(tmpvals.point_matrix[3] * 10.0 + .5))__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "%d", (int)(tmpvals .point_matrix[3] * 10.0 + .5)); |
| 564 | } |
| 565 | sprintf(tmpBuf + strlen(tmpBuf), "-%d-%d%*.*s%d%s",__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "-%d-%d%*.*s%d%s" , tmpvals.x, tmpvals.y, spacingLen, spacingLen, ptr3, tmpvals .width, ptr5) |
| 566 | tmpvals.x, tmpvals.y,__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "-%d-%d%*.*s%d%s" , tmpvals.x, tmpvals.y, spacingLen, spacingLen, ptr3, tmpvals .width, ptr5) |
| 567 | spacingLen, spacingLen, ptr3, tmpvals.width, ptr5)__builtin___sprintf_chk (tmpBuf + strlen(tmpBuf), 0, __builtin_object_size (tmpBuf + strlen(tmpBuf), 2 > 1 ? 1 : 0), "-%d-%d%*.*s%d%s" , tmpvals.x, tmpvals.y, spacingLen, spacingLen, ptr3, tmpvals .width, ptr5); |
| 568 | strcpy(ptr1 + 1, tmpBuf)__builtin___strcpy_chk (ptr1 + 1, tmpBuf, __builtin_object_size (ptr1 + 1, 2 > 1 ? 1 : 0)); |
| 569 | if ((vals->values_supplied & CHARSUBSET_SPECIFIED0x40) && !vals->nranges) |
| 570 | strcat(fname, "[]")__builtin___strcat_chk (fname, "[]", __builtin_object_size (fname , 2 > 1 ? 1 : 0)); |
| 571 | else |
| 572 | append_ranges(fname, vals->nranges, vals->ranges); |
| 573 | break; |
| 574 | } |
| 575 | return TRUE1; |
| 576 | } |
| 577 | |
| 578 | fsRange *FontParseRanges(char *name, int *nranges) |
| 579 | { |
| 580 | int n; |
| 581 | unsigned long l; |
| 582 | char *p1, *p2; |
| 583 | fsRange *result = (fsRange *)0; |
| 584 | |
| 585 | name = strchr(name, '-'); |
| 586 | for (n = 1; name && n < 14; n++) |
| 587 | name = strchr(name + 1, '-'); |
| 588 | |
| 589 | *nranges = 0; |
| 590 | if (!name || !(p1 = strchr(name, '['))) return (fsRange *)0; |
| 591 | p1++; |
| 592 | |
| 593 | while (*p1 && *p1 != ']') |
| 594 | { |
| 595 | fsRange thisrange; |
| 596 | |
| 597 | l = strtol(p1, &p2, 0); |
| 598 | if (p2 == p1 || l > 0xffff) break; |
| 599 | thisrange.max_char_low = thisrange.min_char_low = l & 0xff; |
| 600 | thisrange.max_char_high = thisrange.min_char_high = l >> 8; |
| 601 | |
| 602 | p1 = p2; |
| 603 | if (*p1 == ']' || *p1 == ' ') |
| 604 | { |
| 605 | while (*p1 == ' ') p1++; |
| 606 | if (add_range(&thisrange, nranges, &result, TRUE1) != Successful85) |
| 607 | break; |
| 608 | } |
| 609 | else if (*p1 == '_') |
| 610 | { |
| 611 | l = strtol(++p1, &p2, 0); |
| 612 | if (p2 == p1 || l > 0xffff) break; |
| 613 | thisrange.max_char_low = l & 0xff; |
| 614 | thisrange.max_char_high = l >> 8; |
| 615 | p1 = p2; |
| 616 | if (*p1 == ']' || *p1 == ' ') |
| 617 | { |
| 618 | while (*p1 == ' ') p1++; |
| 619 | if (add_range(&thisrange, nranges, &result, TRUE1) != Successful85) |
| 620 | break; |
| 621 | } |
| 622 | } |
| 623 | else break; |
| 624 | } |
| 625 | |
| 626 | return result; |
| 627 | } |