less stack for the parser - scratchbox hates the big stack usage :)

SVN revision: 30364
This commit is contained in:
Carsten Haitzler 2007-06-17 06:51:42 +00:00
parent aa68331c2a
commit 0d99270bc9
2 changed files with 15 additions and 14 deletions

View File

@ -56,11 +56,13 @@ source_edd(void)
EET_DATA_DESCRIPTOR_ADD_LIST(_font_list_edd, Font_List, "list", list, _font_edd); EET_DATA_DESCRIPTOR_ADD_LIST(_font_list_edd, Font_List, "list", list, _font_edd);
} }
static void source_fetch_file(const char *fil, const char *filname);
static void static void
source_fetch_file(char *fil, char *filname) source_fetch_file(const char *fil, const char *filname)
{ {
FILE *f; FILE *f;
char buf[256 * 1024], *dir = NULL; char buf[16 * 1024], *dir = NULL;
long sz; long sz;
ssize_t dir_len = 0; ssize_t dir_len = 0;
SrcFile *sf; SrcFile *sf;
@ -86,12 +88,13 @@ source_fetch_file(char *fil, char *filname)
while (fgets(buf, sizeof(buf), f)) while (fgets(buf, sizeof(buf), f))
{ {
char *p = buf, *pp; char *p, *pp;
int got_hash = 0; int got_hash = 0;
int forgetit = 0; int forgetit = 0;
int haveinclude = 0; int haveinclude = 0;
char *file = NULL, *fname = NULL; char *file = NULL, *fname = NULL;
p = buf;
while ((!forgetit) && (*p)) while ((!forgetit) && (*p))
{ {
if (!got_hash) if (!got_hash)
@ -122,7 +125,7 @@ source_fetch_file(char *fil, char *filname)
* since according to the standard, preprocessor * since according to the standard, preprocessor
* statements need to be put in column 0. * statements need to be put in column 0.
*/ */
else if (!strncmp (p, "#include", 8)) else if (!strncmp(p, "#include", 8))
{ {
haveinclude = 1; haveinclude = 1;
p += 8; p += 8;
@ -137,10 +140,8 @@ source_fetch_file(char *fil, char *filname)
{ {
char end = '\0'; char end = '\0';
if (*p == '"') if (*p == '"') end = '"';
end = '"'; else if (*p == '<') end = '>';
else if (*p == '<')
end = '>';
if (end) if (end)
{ {
@ -155,7 +156,7 @@ source_fetch_file(char *fil, char *filname)
/* get the directory of the current file /* get the directory of the current file
* if we haven't already done so * if we haven't already done so
*/ */
if (!dir && strrchr(fil, '/')) if ((!dir) && (strrchr(fil, '/')))
{ {
dir = mem_strdup(fil); dir = mem_strdup(fil);
slash = strrchr(dir, '/'); slash = strrchr(dir, '/');
@ -193,7 +194,7 @@ source_fetch_file(char *fil, char *filname)
free(fname); free(fname);
} }
} }
free (dir); free(dir);
fclose(f); fclose(f);
} }