Mike,

Would you be so kind as to test the attached patch and confirm that it
does what you want?  It's rather urgent, I'd like it to go into 4.3.

I'm cut off from CVS right now, sorry if it doesn't apply cleanly.

                                        Juliusz


*** xc/programs/mkfontscale/mkfontscale.c.old	2003-01-27 15:58:08.000000000 +0100
--- xc/programs/mkfontscale/mkfontscale.c	2003-02-06 17:38:53.000000000 +0100
***************
*** 299,304 ****
--- 299,345 ----
      return c;
  }
  
+ static int
+ unsafe(char c)
+ {
+     return 
+         c < 0x20 || c > 0x7E ||
+         c == '[' || c == ']' || c == '(' || c == ')' || c == '\\';
+ }
+ 
+ static char *
+ safe(char* s)
+ {
+     int i, len, safe_flag = 1;
+     char *t;
+ 
+     i = 0;
+     while(s[i] != '\0') {
+         if(unsafe(s[i]))
+             safe_flag = 0;
+         i++;
+     }
+ 
+     if(safe_flag) return s;
+ 
+     len = i;
+     t = malloc(len + 1);
+     if(t == NULL) {
+         perror("Couldn't allocate string");
+         exit(1);
+     }
+ 
+     for(i = 0; i < len; i++) {
+         if(unsafe(s[i]))
+             t[i] = ' ';
+         else
+             t[i] = s[i];
+         i++;
+     }
+     t[i] = '\0';
+     return t;
+ }
+ 
  int
  doDirectory(char *dirname_given)
  {
***************
*** 484,489 ****
--- 525,534 ----
          if(!adstyle) adstyle = "";
          if(!spacing) spacing = "p";
  
+         /* Yes, it's a memory leak. */
+         foundry = safe(foundry);
+         family = safe(family);
+ 
          for(encoding = encodings; encoding; encoding = encoding->next)
              if(checkEncoding(face, encoding->value)) {
                  found = 1;

Reply via email to