Atom bdfGetPropertyValue(char *s) { register char *p, *pp; char *orig_s = s; Atom atom; /* strip leading white space */ while (*s && (*s == ' ' || *s == '\t')) s++; if (*s == 0) { return bdfForceMakeAtom(s, NULL); } if (*s != '"') { pp = s; /* no white space in value */ for (pp = s; *pp; pp++) if (*pp == ' ' || *pp == '\t' || *pp == '\015' || *pp == '\n') { *pp = 0; break; } return bdfForceMakeAtom(s, NULL); } /* quoted string: strip outer quotes and undouble inner quotes */ s++; pp = p = (char *) xalloc((unsigned) strlen(s) + 1); if (pp == NULL) { bdfError("Couldn't allocate property value string (%d)\n", strlen(s) + 1); return None; } while (*s) { if (*s == '"') { if (*(s + 1) != '"') { *p++ = 0; atom = bdfForceMakeAtom(pp, NULL); xfree(pp); return atom; } else { s++; } } *p++ = *s++; } xfree (pp); bdfError("unterminated quoted string property: %s\n", (pointer) orig_s); return None; }
Atom bdfForceMakeAtom(char *str, int *size) { register int len = strlen(str); Atom the_atom; if (size != NULL) *size += len + 1; the_atom = MakeAtom(str, len, TRUE); if (the_atom == None) bdfError("Atom allocation failed\n"); return the_atom; }
Atom bdfForceMakeAtom(char *str, int *size) { register int len = strlen(str); extern Atom MakeAtom(); /* Added this line to be consistent with X.org code */ Atom the_atom; if (size != NULL) *size += len + 1; the_atom = MakeAtom(str, len, TRUE); if (the_atom == None) bdfError("Atom allocation failed\n"); return the_atom; }
unsigned char bdfHexByte(unsigned char *s) { unsigned char b = 0; register char c; int i; for (i = 2; i; i--) { c = *s++; if ((c >= '0') && (c <= '9')) b = (b << 4) + (c - '0'); else if ((c >= 'A') && (c <= 'F')) b = (b << 4) + 10 + (c - 'A'); else if ((c >= 'a') && (c <= 'f')) b = (b << 4) + 10 + (c - 'a'); else bdfError("bad hex char '%c'", c); } return b; }