indent dirwalk.c dirwalk.h
Ran indent on dirwalk code; quite a bit of change.
This commit is contained in:
parent
ba686d601b
commit
b37621c2f0
2 changed files with 247 additions and 246 deletions
|
|
@ -76,6 +76,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||||
{
|
{
|
||||||
int loadable = 0;
|
int loadable = 0;
|
||||||
const char *restrict const cp = strchr(files[i].str, '.');
|
const char *restrict const cp = strchr(files[i].str, '.');
|
||||||
|
|
||||||
show_progress_bar(screen);
|
show_progress_bar(screen);
|
||||||
if (cp)
|
if (cp)
|
||||||
{
|
{
|
||||||
|
|
@ -83,6 +84,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||||
const char * /*restrict */ const suffixes[] =
|
const char * /*restrict */ const suffixes[] =
|
||||||
{ "ttc", "dfont", "pfa", "pfb", "otf", "ttf", };
|
{ "ttc", "dfont", "pfa", "pfb", "otf", "ttf", };
|
||||||
int j = sizeof suffixes / sizeof suffixes[0];
|
int j = sizeof suffixes / sizeof suffixes[0];
|
||||||
|
|
||||||
while (j--)
|
while (j--)
|
||||||
{
|
{
|
||||||
// only check part, because of potential .gz or .bz2 suffix
|
// only check part, because of potential .gz or .bz2 suffix
|
||||||
|
|
@ -106,6 +108,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||||
{
|
{
|
||||||
char fname[512];
|
char fname[512];
|
||||||
TuxPaint_Font *font;
|
TuxPaint_Font *font;
|
||||||
|
|
||||||
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
|
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); //EP
|
printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); //EP
|
||||||
|
|
@ -113,6 +116,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||||
if (locale && strstr(fname, "locale") && !all_locale_fonts)
|
if (locale && strstr(fname, "locale") && !all_locale_fonts)
|
||||||
{
|
{
|
||||||
char fname_check[512];
|
char fname_check[512];
|
||||||
|
|
||||||
/* We're (probably) loading from our locale fonts folder; ONLY load our locale's font */
|
/* We're (probably) loading from our locale fonts folder; ONLY load our locale's font */
|
||||||
snprintf(fname_check, sizeof fname_check, "%s/%s.ttf", dir, locale);
|
snprintf(fname_check, sizeof fname_check, "%s/%s.ttf", dir, locale);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
@ -135,12 +139,11 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int numfaces = TTF_FontFaces(font->ttf_font);
|
int numfaces = TTF_FontFaces(font->ttf_font);
|
||||||
if (numfaces != 1)
|
|
||||||
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str,
|
|
||||||
family, style);
|
|
||||||
|
|
||||||
printf("success: tpf: 0x%x tpf->ttf_font: 0x%x\n",
|
if (numfaces != 1)
|
||||||
(unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->ttf_font); //EP added (intptr_t) to avoid warning on x64
|
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str, family, style);
|
||||||
|
|
||||||
|
printf("success: tpf: 0x%x tpf->ttf_font: 0x%x\n", (unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->ttf_font); //EP added (intptr_t) to avoid warning on x64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// These fonts crash Tux Paint via a library bug.
|
// These fonts crash Tux Paint via a library bug.
|
||||||
|
|
@ -168,16 +171,14 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||||
if (!charset_works(font, gettext("qx")) || !charset_works(font, gettext("QX")))
|
if (!charset_works(font, gettext("qx")) || !charset_works(font, gettext("QX")))
|
||||||
blacklisted = 1;
|
blacklisted = 1;
|
||||||
|
|
||||||
if(!blacklisted){
|
if (!blacklisted)
|
||||||
|
{
|
||||||
if (num_font_styles == num_font_styles_max)
|
if (num_font_styles == num_font_styles_max)
|
||||||
{
|
{
|
||||||
num_font_styles_max = num_font_styles_max * 5 / 4 + 30;
|
num_font_styles_max = num_font_styles_max * 5 / 4 + 30;
|
||||||
user_font_styles =
|
user_font_styles = realloc(user_font_styles, num_font_styles_max * sizeof *user_font_styles);
|
||||||
realloc(user_font_styles,
|
|
||||||
num_font_styles_max * sizeof *user_font_styles);
|
|
||||||
}
|
}
|
||||||
user_font_styles[num_font_styles] =
|
user_font_styles[num_font_styles] = malloc(sizeof *user_font_styles[num_font_styles]);
|
||||||
malloc(sizeof *user_font_styles[num_font_styles]);
|
|
||||||
user_font_styles[num_font_styles]->directory = strdup(dir);
|
user_font_styles[num_font_styles]->directory = strdup(dir);
|
||||||
user_font_styles[num_font_styles]->filename = files[i].str; // steal it (mark NULL below)
|
user_font_styles[num_font_styles]->filename = files[i].str; // steal it (mark NULL below)
|
||||||
user_font_styles[num_font_styles]->family = strdup(family);
|
user_font_styles[num_font_styles]->family = strdup(family);
|
||||||
|
|
@ -233,8 +234,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// THREADED_FONTS
|
// THREADED_FONTS
|
||||||
printf("Font is too defective: %s, %s, %s\n", files[i].str, family,
|
printf("Font is too defective: %s, %s, %s\n", files[i].str, family, style);
|
||||||
style);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
TuxPaint_Font_CloseFont(font);
|
TuxPaint_Font_CloseFont(font);
|
||||||
|
|
@ -258,6 +258,7 @@ int compare_ftw_str(const void *v1, const void *v2)
|
||||||
{
|
{
|
||||||
const char *restrict const s1 = ((tp_ftw_str *) v1)->str;
|
const char *restrict const s1 = ((tp_ftw_str *) v1)->str;
|
||||||
const char *restrict const s2 = ((tp_ftw_str *) v2)->str;
|
const char *restrict const s2 = ((tp_ftw_str *) v2)->str;
|
||||||
|
|
||||||
return -strcmp(s1, s2); /* FIXME: Should we try strcasecmp, to group things together despite uppercase/lowercase in filenames (e.g., Jigsaw* vs jigsaw* Starters)??? -bjk 2009.10.11 */
|
return -strcmp(s1, s2); /* FIXME: Should we try strcasecmp, to group things together despite uppercase/lowercase in filenames (e.g., Jigsaw* vs jigsaw* Starters)??? -bjk 2009.10.11 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,8 +266,7 @@ void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||||
int rsrc, void (*fn) (SDL_Surface * screen,
|
int rsrc, void (*fn) (SDL_Surface * screen,
|
||||||
const char *restrict const dir,
|
const char *restrict const dir,
|
||||||
unsigned dirlen, tp_ftw_str * files,
|
unsigned dirlen, tp_ftw_str * files,
|
||||||
unsigned count, const char *restrict const locale),
|
unsigned count, const char *restrict const locale), const char *restrict const locale)
|
||||||
const char *restrict const locale)
|
|
||||||
{
|
{
|
||||||
DIR *d;
|
DIR *d;
|
||||||
unsigned num_file_names = 0;
|
unsigned num_file_names = 0;
|
||||||
|
|
@ -326,6 +326,7 @@ void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||||
if (filetype == TP_FTW_UNKNOWN)
|
if (filetype == TP_FTW_UNKNOWN)
|
||||||
{
|
{
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
|
|
||||||
memcpy(dir + dirlen, f->d_name, d_namlen + 1);
|
memcpy(dir + dirlen, f->d_name, d_namlen + 1);
|
||||||
if (stat(dir, &sbuf))
|
if (stat(dir, &sbuf))
|
||||||
continue; // oh well... try the next one
|
continue; // oh well... try the next one
|
||||||
|
|
@ -362,6 +363,7 @@ void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||||
if (filetype == TP_FTW_DIRECTORY)
|
if (filetype == TP_FTW_DIRECTORY)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if (num_dir_names == max_dir_names)
|
if (num_dir_names == max_dir_names)
|
||||||
{
|
{
|
||||||
max_dir_names = max_dir_names * 5 / 4 + 3;
|
max_dir_names = max_dir_names * 5 / 4 + 3;
|
||||||
|
|
@ -399,8 +401,7 @@ void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen,
|
||||||
qsort(dir_names, num_dir_names, sizeof *dir_names, compare_ftw_str);
|
qsort(dir_names, num_dir_names, sizeof *dir_names, compare_ftw_str);
|
||||||
while (num_dir_names--)
|
while (num_dir_names--)
|
||||||
{
|
{
|
||||||
memcpy(dir + dirlen, dir_names[num_dir_names].str,
|
memcpy(dir + dirlen, dir_names[num_dir_names].str, dir_names[num_dir_names].len + 1);
|
||||||
dir_names[num_dir_names].len + 1);
|
|
||||||
tp_ftw(screen, dir, dirlen + dir_names[num_dir_names].len, rsrc, fn, locale);
|
tp_ftw(screen, dir, dirlen + dir_names[num_dir_names].len, rsrc, fn, locale);
|
||||||
free(dir_names[num_dir_names].str);
|
free(dir_names[num_dir_names].str);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue