mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 17:41:05 +00:00
Fosdem updates.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20805 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cdbd239478
commit
d650d89cb9
8 changed files with 200 additions and 98 deletions
55
NSCharacterSets/dataToHeader.c
Normal file
55
NSCharacterSets/dataToHeader.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* A trivial C program to read characterset data files and produce a C
|
||||
* header file to be included into NSCharacterSet.m
|
||||
* Pass it the names of the data files as arguments.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int c;
|
||||
FILE *o;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "Expecting names of data files to convert\n");
|
||||
return 1;
|
||||
}
|
||||
o = fopen("NSCharacterSetData.h", "w");
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
FILE *f;
|
||||
char name[BUFSIZ];
|
||||
int j;
|
||||
int sep = '{';
|
||||
|
||||
strcpy(name, argv[i]);
|
||||
j = strlen(name) - 4;
|
||||
if (j < 0 || strcmp(&name[j], ".dat") != 0)
|
||||
{
|
||||
fprintf(stderr, "Bad file name '%s'\n", name);
|
||||
return 1;
|
||||
}
|
||||
f = fopen(name, "r");
|
||||
if (f == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to read '%s'\n", name);
|
||||
return 1;
|
||||
}
|
||||
name[j] = '\0';
|
||||
fprintf(o, "static unsigned char %s[8192] = ", name);
|
||||
while ((c = fgetc(f)) != EOF)
|
||||
{
|
||||
fprintf(o, "%c\n'\\x%02x'", sep, c);
|
||||
sep = ',';
|
||||
}
|
||||
fprintf(o,"};\n");
|
||||
fclose(f);
|
||||
}
|
||||
fclose(o);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue